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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
roisolberg
Creator
Creator

YTD calculations not working with variable

Hi All,

First, i know there has been many posts and questions regarding this issue, but i haven't found a solution 

i am trying to make a YTD/LYTD calculations, that will count the number of opened projects in 2018 vs 2019

iv'e defined a master calendar and it is working well and in it i defined :

If( TempDate - YearStart(TempDate) <= Today() - YearStart(Today()), 1, 0 ) as IsInYTD

so far so good, now i tried doing a bar chart to compare 2019-2018 by month

so i defined the variables in the UI variables (Based on my calendar)

vMaxDate - Max(KickOffDate)

vMaxYear - Max(KickOffYear)

vPriorYear - Max(KickOffYear)-1

and than i tried to do the set expression that will count the number of projects in that time period,

when i do the set expression using {'2019'}  and  {'2018'}  it works, but when i use variables it makes the sum of 2018+2019

*CountProjects is defined in the project table '1 as CountProjects'

Count( {$<IsInYTD={1},KickOffYear={'2019'}>} CountProjects ) 

Count( {$<IsInYTD={1},KickOffYear={'2018'}>} CountProjects )

clipboard_image_0.png

when i try to change it to the variable using this set:


Count( {$<IsInYTD={1},KickOffYear={'=$(vMaxYear)'}>} CountProjects ) - 2019

Count( {$<IsInYTD={1},KickOffYear={'=$(vPriorYear)'}>} CountProjects )  - 2018

 

i get the same value for both:

clipboard_image_1.png

 

iv'e tried looking for this in older posts but no matter how i tried i didn't get the right calculation if any.

any ideas?

Thanks!

 

 

 

 

Labels (2)
11 Replies
roisolberg
Creator
Creator
Author

wow,

thank you very much for a very good and explained solution!!

this was very helpful both to my model and my knowledge.  🙂 

 

 

 

Shubham_Deshmukh
Specialist
Specialist

Hi @gmenoutis ,

That' great knowledge sharing.

Can u pls put some light on my revert, why it is not working in @roisolberg 's case?

-Shubham