Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
AnalyticsDev
Contributor III
Contributor III

Year over Year percent change in line chart

Hi,
I have a requirement to display Year over Year percentage change in a line charge.

Dimension: StatusYear

Field to sum: Quantity.

Basically, I need to have StatusYear on the X axis (the available data shows us years dating back to 2018) and the percent increase or decrease from the PREVIOUs year along the Y axis in a line chart.  

Example: If in 2023 the sum quantity was 149 and the sum quantity in 2022 was 145 I'd imagine the calculation should be: 149-144 =  5. 5/149 = .0335.  .0335 * 100 = 3.35% gain from 2022 to 2023.

I need that small percentage to show for each year how much it gained or lost from the previous year.  

I have something similar in a KPI box and it works for one year displayed in the KPI box but I need it to work in a chart with months across the X axis StatusYear and this formula doesnt do that.

(Sum({<StatusYear = {"$(=Max(StatusYear))"} >} Quantity) -
sum({<StatusYear = , Month = , status_date={">=$(=YearStart(addYears(max(status_date),-1)))"}, PreviousMonthYear={"<=$(=addmonths(MonthEnd(max(status_date)),-23))"}>}Quantity))
/ Sum({<StatusYear = {"$(=Max(StatusYear))"} >} Quantity)

 

Thanks in advance.

 

Labels (1)
1 Solution

Accepted Solutions
MatheusC
Specialist
Specialist

@AnalyticsDev 
Check out the above() function; it will look at the line above the current line.

https://help.qlik.com/en-US/sense/May2024/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/InterRecor...

sum(Quantity)
/
Above(sum(Quantity),1)-1


- Matheus

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!

View solution in original post

2 Replies
MatheusC
Specialist
Specialist

@AnalyticsDev 
Check out the above() function; it will look at the line above the current line.

https://help.qlik.com/en-US/sense/May2024/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/InterRecor...

sum(Quantity)
/
Above(sum(Quantity),1)-1


- Matheus

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!
Kushal_Chawda

@AnalyticsDev try below expression

Sum(Quantity)/sum(aggr(Above(total Sum({<Year>}Quantity)),(Year,(NUMERIC,ASCENDING))))-1