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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to Get YTD values into Variable

Hi all,

I've to create a variable which calculates YTD and Previous year YTD.

Here is my requirements.

For Prev YTD it has to calculate from Jan to Dec.ie Jan 2015 to Dec 2015. and

Current year YTD calculated from Jan to till current month ie from Jan 2016 to Feb 2016.

Can Anyone help me .

Thanks In Advance.

Thanks,

Anusha

2 Replies
jolivares
Specialist
Specialist

Use set analysis to do that.

Current Year     :     Sum(Sales)

Past Year          :     Sum({<MyYear={$(=Max(MyYear)-1), MyMonth}>} Sales)

When you select 2016, the second expression calculate last year.  Take care with de Month selected, in this case I include the month in the set in order you have the full year.

HirisH_V7
Master
Master

Hi,

may be like this,

Current Year:

Sum({<Year=, Month=, Quarter=, Week=, DateField=, DateNum={">=$(=Num(YearStart(Max(DateNum))))<=$(=Max(DateNum))"}>} Sales)


Previous Year:

Sum({<Year=, Month=, Quarter=, Week=, DateField=, DateNum={">=$(=Num(YearStart(Max(DateNum))-1))<=$(=Max(DateNum))"}>} Sales)


HTH,

Hirish

HirisH