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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
TomBond77
Specialist
Specialist

Rolling 12 months with 'MMM YYYY'

Hi experts

I need this formula, set expression, working dynamically:

Sum({<[Year/Month]={'Feb 2022','Mar 2022','Apr 2022','May 2022','Jun 2022','Jul 2022','Aug 2022','Sep 2022','Oct 2022','Nov 2022','Dec 2022','Jan 2023'}>} [Amount])

I have defined this formula to be dynamically, but the result is '0' for amount. 

Sum({<[Year/Month]={'>=$(=MonthName(Addmonths(Max([Year/Month]),-11, 'MMM YYYY')))<=$(=Date(Max([Year/Month]), 'MMM YYYY'))'}>}
[Amount])

The resolution is fine. Where is the error?

TomBond77_0-1675155154648.png

TomBond77_1-1675155033870.png

 


,

Labels (5)
3 Replies
ogster1974
Partner - Master II
Partner - Master II

assuming thats part of your master calendar take a step back and use your date not a period label.

sum({<[Date]={">$(=AddMonths(Max(MonthStart([Date])),-12))"}>} Amount)

 

 

vinieme12
Champion III
Champion III

[Year/Month]  is a text field, you cannot use operators like >,< on text values

Best to  use the Datefield in your dataset instead

As below

= sum({<Datefield={">=$(=YearStart(Max(Datefield)))<$(=Date(Max(Datefield)))"}>}Amount)

 

Or if you don't have a date field, create one while loading the data as below

MonthStart(Date#([Year/Month],'MMM YYYY')) as Datefield

 

 

Or Try below

 

= sum({<"=MonthStart(Date#([Year/Month],'MMM YYYY'))"={">=$(=YearStart(Max(Date#([Year/Month],'MMM YYYY'))))<$(=MonthStart(Max(Date#([Year/Month],'MMM YYYY'))))"}>}Amount)

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
ogster1974
Partner - Master II
Partner - Master II

Plus your example with single quotes means text match what's within so you might as well have been asking for [Year/Month]={'Elephant'} the result would be the same 0.