Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
@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
@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
@AnalyticsDev try below expression
Sum(Quantity)/sum(aggr(Above(total Sum({<Year>}Quantity)),(Year,(NUMERIC,ASCENDING))))-1