Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
andewan
Contributor II
Contributor II

Display previous year value in current year in a table

Input data

Account Year Month Amount
Equity 2021 12 50
Equity 2022 01 82
Equity 2022 ....  
Equity 2022 ........  
Equity 2022 ............  
Equity 2022 12 92
Equity 2023 01 75

 

Need to show pivot table:

  2023 2022
  01 01
Equity: Prior year December 92 50
Equity: Current year January 75 82
(Column(1) + Column(2))/2 83,5 66

 

I am trying to calculate  Equity: Prior year December based on the set expression below but not  getting the desired result. 

SUM(
{<
ACCOUNT =  {'Equity'},
MONTH = {'12'},
YEAR = { $(=ONLY(YEAR)-1) },
>}
AMOUNT)

Labels (2)
3 Replies
Or
MVP
MVP

Has a year been selected? If not, Only(Year) will return null since more than one year is possible. It may be better to use Max(Year).

andewan
Contributor II
Contributor II
Author

No year has been selected. There is no Year filter, in fact. 

I want the Year column/dimension label to be used as a deciding factor in displaying values from the previous year. 

If I change from Only to Max, I get the below result. So now I get 92 and 50 but still under 2022-12 and 2021-12. I want 92 under 2023-01 and 50 under 2022-01

Equity: Prior year December =

SUM(
{<
Account = {'Equity'},
Month = {'12'},
Year = { $(=MAX(Year)-1), $(=MAX(Year)-2) }
>

}
Amount)

andewan_0-1679484783104.png

 

Touix
Contributor III
Contributor III

Hello Andewan,

 

Have you got any answer of your problematic ? I have exactly the same .