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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
sandeepprasad_j
Creator
Creator

Need help in calculating the YTD

Hi Experts,

I am using the below expressing for calculating the Six months trailing period

SET ANALYSIS EXPRESSION:-

sum({<Year=,[Month Name Short Year]=,date_con ={'>=$(=addmonths(max(date_con),-5))<=$(=max(date_con))'},[Metric_ID] ={'OP_001'} >}Result)

Now i have to calculate the YTD ... So is there any way to calculate the YTD by changing the above expression...

or

IF there is another way to calculate the YTD

Urgent...Please ...

Regards,

Sandeep.

7 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Try with this

sum({<Year=,[Month Name Short Year]=,date_con ={'>=$(=YearStart(max(date_con)))<=$(=max(date_con))'},[Metric_ID] ={'OP_001'} >}Result)

michael_maeuser
Partner Ambassador
Partner Ambassador

i would do that: create a variable vMaxYear= =Year(Today(date_con)) and another vToday =date(Today())

then try the expression:

sum({<Year={$(vMaxYear)}, date_con={'<=$(vToday)}>} Result)

v_iyyappan
Specialist
Specialist

Hi

Use like this

Set the variable :

vSelectDate = MakeDate(Year(Max(date_con)),Month(Max(date_con)),Day(Max(date_con)))

=Sum({<Year=,[Month Name Short Year]=,date_con ={'>=$(=YearStart(vSelectDate))<=$(=vSelectDate)'},[Metric_ID] ={'OP_001'} >}Result)

Regards,

sandeepprasad_j
Creator
Creator
Author

The above expression seems to be working ... Can i know how to give the starting Month as April  and ending month as march ... can u please help on this ...

MayilVahanan

HI

Try like this

sum({<Year=,[Month Name Short Year]=,date_con ={'>=$(=YearStart(max(date_con),0,4))<=$(=YearEnd(max(date_con),0,4))'},[Metric_ID] ={'OP_001'} >}Result)

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
v_iyyappan
Specialist
Specialist

Hi,

First give the variable like this:

vSelect= MakeDate(Year(Max(date_con)),Month(Max(date_con)),Day(Max(date_con)))

you can arrive in march :

=MonthStart(vSelect,-2)

April:

MonthEnd(vSelect,-3)

Hope its help,

Iyyappan

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

You have mention the start month in the YearStart function

YearStart(max(date_con), 0, 4)

Try this

sum({<Year=,[Month Name Short Year]=,date_con ={'>=$(=YearStart(max(date_con), 0, 4))<=$(=max(date_con))'},[Metric_ID] ={'OP_001'} >}Result)


Hope it helps