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: 
piyush_s11
Creator
Creator

YTD calculation Logic help needed

Hi,

I want to calculate YTD. For ex : If I select Month as Sep 2019 then I should get value from Jan-19 to Sep-19.

I have written below code for this

 

=$(vAmount(Month={">=$(=YearStart(Max(Month)))<= $(=Date(Max(Month)))"},items = {'cost_plus','profit_split','fee_spread'},_Region=,BU_CODE=)) 

the highlighted portion is for ytd calulation. but it is not working. could please assist what is going wrong in the formula.

YTD Calculation.PNG

in above is the screenshot of the same formula. in this before <= sign the default qlik functions are not highlighting in blue color like yearstart & max function is not highlighting in blue. after this sign the qlik functions are highlighting in blue.

is there any error in formula ?. Please note Month field is a text value not in date format.

Thanks. 

Labels (2)
10 Replies
piyush_s11
Creator
Creator
Author

Hi Sunny,

Thanks for your kind reply with solution.

If I want to calculate ytd based on variable then how the formula would be?

you can consider my formula

Month={">=$(=YearStart(Max(Month)))<= $(=Date(Max(Month)))"}

how I can replace a month with a variable which I have declared in variable declaration to calculate ytd