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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
mrainey18
Creator
Creator

Variable and Set Analysis

I am trying to do a sum of months less than the current month/year:

Sum({<[CalendarDate.autoCalendar.YearMonth] =- { '$( =$(vCurrMonthYear) )' }>}Total)

vCurrMonthYear = MonthName(addmonths(today(),-1))

This does not work.  Any other ideas?

1 Solution

Accepted Solutions
mrainey18
Creator
Creator
Author

Got it:

Sum({$<CalendarDate = { "$(='<' & $(vCurrMonthYear))" }>}Total)

vCurrMonthYear = num(MonthName(addmonths(today(),0)))

View solution in original post

5 Replies
Clever_Anjos
Support
Support

Which format are your variable output and your calendar field? Are they the same?

mrainey18
Creator
Creator
Author

They are the same. 

Clever_Anjos
Support
Support

Could you double check?

mrainey18
Creator
Creator
Author

Yes.  I did check.  They match both are formatted "MMM YYYY"

Should I use a different format?  I tried num() but couldnt get the less than to work.  Do you know how to do that?

Something like this:

vCurrMonthYear = num(MonthName(addmonths(today(),-1)))

Not sure where to put the <..

Sum({<CalendarDate =- { '$( =$(vCurrMonthYear) )' }>}Total)

CalendarDate is already the min number of each month.

mrainey18
Creator
Creator
Author

Got it:

Sum({$<CalendarDate = { "$(='<' & $(vCurrMonthYear))" }>}Total)

vCurrMonthYear = num(MonthName(addmonths(today(),0)))