Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
surajap123
Creator III
Creator III

YTD analysis for previous year

When i am doing Year to Date comparison with current vs Previous year, I am writing below expressions-

For current YTD analysis->

=SUM({<Year={'$(=Max(Year)'},Date={'<=$(=Max(Date)'}>}Total)

or

=SUM({<Year={'$(=Max(Year)'}>}Total)

Both the above expresssions gives same result to get values for the current year in straight table.

For previous YTD analysis->

=SUM({<Year={'$(=Max(Year)-1'},Date={'<=$(=addyears(Max(Date),-1))'}>}Total)

or

=sum({<Year={$(=Max(Year)-1)}>}Total)

But for the previous YTD analysis, both the above expressions doesnt give same result.

-I understand that because here the second expression gives result for the whole year.

Am i correct?

-While doing YTD analysis for previous year, which above expression should i need to use?

-Also is it important to use Month=,Day=,MonthYear=, in the set analysis in YTD expreesion?

1 Solution

Accepted Solutions
Not applicable

You are right and I think you should use the first one

=SUM({<Year={'$(=Max(Year)-1'},Date={'<=$(=addyears(Max(Date),-1))'}>}Total)

as name says YTD, Year to Date for current year ideally should not be compared to complete previous year.

View solution in original post

4 Replies
Not applicable

You are right and I think you should use the first one

=SUM({<Year={'$(=Max(Year)-1'},Date={'<=$(=addyears(Max(Date),-1))'}>}Total)

as name says YTD, Year to Date for current year ideally should not be compared to complete previous year.

maxgro
MVP
MVP

you ask "-Also is it important to use Month=,Day=,MonthYear=, in the set analysis in YTD expreesion?"


it depends: if you add list boxes for these 3 fields, selecting in these list box will modify the result of your expressions

if you want to disregard selections in Month, add Month=

same for other fields

surajap123
Creator III
Creator III
Author

Thanks everyone for the clear answers..

Not applicable

for this type of calculation I am getting previous total is wrong ... my straight table is comparing the current year and previous yar...

teacher name    current yearsalary        previous year salary

for this current year cumulative total salary is coming correct, but previous year total salary is wrong ie cumulative total salary.

any clue.. I posted the information in my new thread

 

https://community.qlik.com/message/941380#941380