Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
abubakarsiddiq7
Contributor III
Contributor III

YTD Issue with YYYYMM format

Hi Experts,

 

I am unable to get the YTD Value . Please help me here  Sample data is attached.

 

 

1 Reply
Or
MVP
MVP

Load ID, YearMonth, Sales, if(YearMonth <= Year(Today())*100 + Month(Today()) AND YearMonth >= Year(Today())*100, 1) as YTD_Flag From YourTable;

To sum, then use Sum({< YTD_Flag = {1} >}Sales)

You could also write the same code into your set analysis but if you plan to use it for other fields, it's often better to create a flag in the script, so that's what I suggested.

 

Note that this assumes the current month is included in the YTD calculation. If you only want completed months (e.g. currently September would be included and October would  not), replace the <= with a < in the first section of the if() statement.