Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

YTD vs LYTD


I have calculations that are year to date and last year to date.  These work well but I have been asked to change them so that we are more looking at the data of number of working days vs just calendar days.

Example:  If this year the first of the month falls on a Monday but last year it feel on and Sunday and today is the 4th day of the month.  Then we would minus one of the days from this year so that both YTD and LYTD have the same number of working days for this month.  (I am not worried about if past months days are not the same amount just at the start of each month if the number of working days are the same.)

Does this make any sense?  I am not sure what I need to do to ether add or subtract and day.


Expression
YTD

Sum ([Sales] * CurYTDFlag)

Last YTD

Sum ([Sales] * LastYTDFlag )

2 Replies
Not applicable
Author

Hi,

I believe the best way is to create cumulative sum of your CurYTDFlag and LastYTDFlag calculations in the script.

Then a create a new CurYTDFlag (to use in the expression) with a condition that turns the last occurrence of 1 in the original CurYTDFlag to 0 if CumSumCurrYTDFlag <> CumSumLastYTDFlag.

I hope the solution is helpful.


Kind regards,

Nuno


prieper
Master II
Master II

Believe it might be better to work with NETWORKDAYS to determine the number of workingdays and then use the result in the FIRSTWORKDAY-function.

Might also be better to work with SET-Analysis rather than with flags.

HTH Peter