Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
yvonne-c
Creator
Creator

Previous 12 months expression

I am using the following expression to calculate between two dates

Sum({<Date ={">=$(vStartDate)<=$(vEndDate)"}>} Price)

I also want to calculate the same period for the previous 12 months

I have tried the following expressions but cannot get them to work.

    Sum({<Date={"=Date>=addmonths(vStartDate,-12) and Date<=addmonths(vEndDate,-12)"}>} Price)

     Sum({$<Date ={">=$(=Num(AddMonths(vStartDate, -12)))<=$(=Num(AddMonths(vEndDate, -12)))"}>}Price)

Can anybody advise?

Thanks

1 Solution

Accepted Solutions
sunny_talwar

May be try this

Sum({<Date={"=Only({1} Date) >= AddMonths(vStartDate, -12) and Only({1} Date) <= AddMonths(vEndDate, -12)"}>} Price)

View solution in original post

3 Replies
sunny_talwar

What is the format of your date field? Also, are you making selection in Date or another date and time related fields?

sunny_talwar

May be try this

Sum({<Date={"=Only({1} Date) >= AddMonths(vStartDate, -12) and Only({1} Date) <= AddMonths(vEndDate, -12)"}>} Price)

yvonne-c
Creator
Creator
Author

Thanks Sunny

This one seems to be working