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: 
cramkumar86
Contributor III
Contributor III

To find % difference between current and previous row

I have a table that shows number of resignations week on week. Each date listed below is a Friday. The sample data looks like below.

DateValue    Resignations

5/5/2023      5

5/12/2023    19

5/19/2023    12

5/26/2023     7

I would like to calculate a new column showing the % difference. Example. (Current -Previous)/Previous. The first row in the table can also have the same formula as the previous week's data will be available in the data source although not listed in the table. Please help.

4 Replies
Rajashekar
Contributor III
Contributor III

Hi, try using 'above' function.

cramkumar86
Contributor III
Contributor III
Author

Thanks Raja. The 'above' function works only until the 2nd row. The first row comes as blank. I would also like to compare the resignation on first row with previous week and populate the percentage.

Rajashekar
Contributor III
Contributor III

hi, then you need to create field in backend. 

Here is something I tried. Hope this helps.

Load *,
Previous(Resignations) as PreReg,
    (Resignations-Previous(Resignations))/Previous(Resignations) as PercentChange
    
    ;
 
load * Inline [
 
DateValue,Resignations
3/3/2021,10
4/4/2022,9
5/5/2023,5
5/12/2023,19
5/19/2023,12
5/26/2023,7
 
];
 
 
Gabbar
Specialist
Specialist

Use this as a measure:-
(Resignations - aggr(Above(Resignations),DateValue))/aggr(Above(Resignations),DateValue)

and then You can use formatting to Change it to percent