Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
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