Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Save $600 on Qlik Connect registration! Sign up by Dec. 6 to get an extra $100 off with code CYBERSAVE: REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Harry_FF
Contributor II
Contributor II

Placing YTD,MTD,QTD,PyYTD in a single set using variables

Hi guys, 

want to place YTD,MTD,PyYTD..etc.... in to a variable Input chart, so If I select YTD then data should be filter Year to date, N MTD then Month to date.

Normal Calculation for YTD,MTD.....

YTD

 Count({< datefield 1= {“ >=$(=Yearstart(Today())) <Today()”}  >} Items )

MTD

Avg ({< datefield 2= {“ >=$(=MonthaStart(Today())) <Today()”}  >} Profits )

Prev YTD

Sum({< datefield 3= {“ >=$(=YearStart(Today(),-1))) <$(=AddYears(Today(),-1))”}  >} Sales )

Instead of writing Them separately . Now I have many charts with Different Date fields  which are Of same format. 

Now I create a empty variable (vDtselect) to place in variable input chart . Now I add Values in this chart as below 

Label YTD 

Value: ‘{“ >=$(=Yearstart(Today())) <Today()”}‘

Label MTD 

value: ‘{“ >=$(=MonthaStart(Today())) <Today()”} ‘

Label Py YTD

Value: ‘{“ >=$(=Yearstart(Today(),-1)) <=$(=Addyears(Today(),-1)”}‘

Label Alldates

Value:  null

now I place  variable in set as below 

chart1 

Count ({< Datefield 1=  $(vDtselect) >} Items) 

chart2

Sum ({< Datefield 2 = $(vDtselect) >} Sales) ........ so on  

now change the Values using Variabie input Chart to get Different Dateperiods .  Similar can Have last 6 months, QTD, Last week So on.... To filter required Date periods for the multiple Charts. I found this Useful and Posted 🙂

Regards ,

Harish .

Labels (1)
0 Replies