Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

YTD Set Analysis

Hi

I have the following expression for my YTD calculation in a straight table -

sum({<Year={$(vMaxYear)},Date={'<=$(vMaxDate)'},Month=,Drawer={'4'}>}JrnAmt). The db has records from 1 July 2011 onwards so this expression works for YTD up to Dec 2011.

The problem with this is that when the  'Jan 2012' is selected, the total for YTD is only for 'Jan 2012' instead of 'Jul 2011' to 'Jan 2012' (Fiscal year is 'Jul' to 'Jun'). So if  'Jan' is selected the YTD sum should be for 'Jul 2011' to 'Jan 2012'.

Is there a way to change this set analysis so that the desired result is achieved without having to build a calender in the script?

Regards

Danie

1 Reply
lironbaram
Partner - Master III
Partner - Master III

hei

you  can set a varaible with this formula

vMinDateYTD=if(num(month(vMaxDate))<=6,makedate(max(Year)-1,7,1),makedate(max(Year),7,1));

then your set analysis will be

sum({<Year,Date={'>=$(vMinDateYTD)    <=$(vMaxDate)'},Month=,Drawer={'4'}>}JrnAmt).