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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
rtun
Contributor
Contributor

Subtract from previous year total

Hello all,

I have a total for the year 2021 and I'm working on an expression for future years until 2030 by subtracting from the previous year something like;

if 2021 has a total of 1000

then 2022 has a total of 1000-100=900

2023 has a total of 800

2024 has a total of 700

Can anyone help me ? I’m struggling to find the correct solution for a few days.

Thanks in advance for your help.

Labels (4)
3 Replies
vinieme12
Champion III
Champion III

can you post some sample data? also confirm if you are trying to achieve this at a chart level or script

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
rtun
Contributor
Contributor
Author

It is a chart.  I used the expression below;

if (Year = 2021, sum ({$<fType ={'DDG'}>}fAmount),
if (Year > 2021, sum({$<Year> - 1}fAmount) - 100))

Basically, I just want to come up with an expression that gives me a subtraction of 100 from the previous year total. 

vinieme12
Champion III
Champion III

Try below

 

Current Year sum ({<fType ={'DDG'}, Year={"$(=Max(Year))"}>}fAmount)

Previous Year = sum ({<fType ={'DDG'}, Year={"$(=Max(Year)-1)"}>}fAmount)

 

Previous Year - 100 = sum ({<fType ={'DDG'}, Year={"$(=Max(Year)-1)"}>}fAmount) - 100

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.