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: 
pelle90
Contributor II
Contributor II

YTD with variable?

Hi. I have loaded some variables through a script and these variables I want to use to create YTD, MTD and QTD which I then can use to see how sales, margin and so on has been YTD, MTD and so on.

 

I have created the following variables. My question is then, how do I proceed in the best way? Can I create a master item for YTD time dimension together with the variables and this master item I can specify for different measures?

Like yeartodate(CurrentDate)    save as masteritem YTD. Then want to use it for measurements sale and margin.

SUM(YTD(sale)). What does the code look like in that case?

 

Let StartDate = num(date('2005-07-01','YYYYMMDD'));

Let CurrentDate=num(date('2010-06-30','YYYYMMDD'));

Let EndDate = num(date('2010-12-31','YYYYMMDD'));

Let YesterdayDate=num($(CurrentDate))-1 ;

Let CurrentYear=Year($(CurrentDate));

Let LY_YTD=num(AddMonths($(CurrentDate),-12,0));

Let DaysToEnd=Monthend($(CurrentDate))-$(CurrentDate);

Let Timespan=Year(Today())-Year(Date($(StartDate)));

Let vCurrentYearMonth = Year($(CurrentDate))&num(month($(CurrentDate)),00);

 

Thanks in advance!

Labels (1)
  • ytd

0 Replies