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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

KPI comparison current year vs previous year

I have a small problem and I was wandering if anyone could help me. I've looked other threads, but couldn't solve it.

For selected year total sales KPI I created this expression:

Sum({$<OrderDate.autoCalendar={Year}>}Sales)

Now I'm having trouble doing it for the previous year total sales KPI that I want to put next to the first one.

How do I do it?

Thanks in advance.

1 Solution

Accepted Solutions
thi_pham
Creator III
Creator III

Previous year:

Sum({<[OrderDate.autoCalendar.Year] = {"$(=Max(Year(OrderDate)) - 1)"}>} Sales)

Current year:

Sum({<[OrderDate.autoCalendar.Year] = {"$(=Max(Year(OrderDate)))"}>} Sales)

It will be based on your selection to get what is the lastest(max) possible year, and minor 1 to get its previous year.

I agree with Jerry Jackson on solution: Sum({$<OrderDate.autoCalendar.YearsAgo={1}>}Sales)

Why dont it work?

@

View solution in original post

7 Replies
jwjackso
Specialist III
Specialist III

Try:


Sum({$<OrderDate.autoCalendar.YearsAgo={1}>}Sales)

Anonymous
Not applicable
Author

Thanks Jerry for the answer, but it doesn't work.

jwjackso
Specialist III
Specialist III

Prior Year:

Sum({<Year=,OrderDate={">=$(=YearStart(MakeDate(Max(Year)),-1))<=$(=YearEnd(MakeDate(Max(Year)),-1))"}>}Sales)

Current Year:

Sum({<Year=,OrderDate={">=$(=YearStart(MakeDate(Max(Year))))<=$(=YearEnd(MakeDate(Max(Year))))"}>}Sales)

Anonymous
Not applicable
Author

Thanks again Jerry, but still nothing.

thi_pham
Creator III
Creator III

Previous year:

Sum({<[OrderDate.autoCalendar.Year] = {"$(=Max(Year(OrderDate)) - 1)"}>} Sales)

Current year:

Sum({<[OrderDate.autoCalendar.Year] = {"$(=Max(Year(OrderDate)))"}>} Sales)

It will be based on your selection to get what is the lastest(max) possible year, and minor 1 to get its previous year.

I agree with Jerry Jackson on solution: Sum({$<OrderDate.autoCalendar.YearsAgo={1}>}Sales)

Why dont it work?

@

Anonymous
Not applicable
Author

Thanks Phi, your solution worked, no idea why Jerry's didnt

Thanks a lot to both of you.

Cheers

simonsiplak
Contributor II
Contributor II

Hello guys,

I am solving same issue I believe, but I can't find right solution. Can you help me? . This works correctly "Sum(Invoice_item_converted_price)" if I select date Service_generated_datetime.autoCalendar.YearMonth.

I want to show in table also previous year sales for selected YearMonth, but it doesn't work

Sum({<[Service_generated_datetime.autoCalendar.Year] = {"$(=Max(Year(Service_generated_datetime))-1)"}>} Invoice_item_converted_price)