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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Koen_D
Contributor III
Contributor III

Ratio yearmonth to last yearmonth

Hi Qlik experts,

I have data containing dates and sales, and a master calendar with YTD field.

I want to show a ratio of this years sales compared to last year sales in a table containing a yearmonth field. The solution I tried is this:

=Sum({<Year = {$=Max(Year)}>}Sales) / =Sum({<Year = {$=Max(Year) - 1}>}Sales)

But it shows no solution, I think because of the set analysis on both 2024 as 2023. Do you expers have a solution for this?

Labels (1)
1 Solution

Accepted Solutions
Kushal_Chawda

@Koen_D  if you make selection on month and sort your YearMonth just above is not enough so try below

=Sum(Sales)/aggr(above(total Sum({<YearMonth>}Sales),12),(YearMonth,(NUMERIC,ASCENDING)))

View solution in original post

3 Replies
Kushal_Chawda

@Koen_D  If you have year month field in your table, you may need to try above() function. Make sure that you

=Sum(Sales) / 
above(total Sum({<YearMonth>}Amount),12)*avg(1)

 

Kushal_Chawda

@Koen_D  if you make selection on month and sort your YearMonth just above is not enough so try below

=Sum(Sales)/aggr(above(total Sum({<YearMonth>}Sales),12),(YearMonth,(NUMERIC,ASCENDING)))
Koen_D
Contributor III
Contributor III
Author

Works like a charm! Thanks Kushal!