Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to get previous value?


Hi folks,

I have a Table like this below

ID NAMEVALUE
1A4000
2B2800
3C1000
4D8000
5E4500
6F7000

Here I want a Chart with Expression of

Expression : Avg(VALUE) - Avg(Previous VALUE)

i want out put like while calculating avg(value)-avg(previous value)

here avg(value) is talking rowno 1 - previous value is not there

avg(value) means rowno 2- previous value(rowno 1)   =  rowno 2 - row no 1

avg(value) means rowno 3-previous value(rowno 2 ) rowno 3- row no 2

avg(value) means rowno 4-previous value(rowno 3 ) rowno 4- row no 3

here(-)  is minus .

7 Replies
anbu1984
Master III
Master III

Dimension: ID, NAME

Expression: Avg(VALUE) - Alt(Above(TOTAL Column(1)),0)

Anonymous
Not applicable
Author

  Alt(Above(TOTAL Column(1)),0)  -         here column1 will take from   value field?


intially i have tried like         Above(sum(value),1)   but it did not given result

Not applicable
Author

Hi,

Avg(VALUE) - Alt(Above(TOTAL Column(1)),0) -- its working fine.

A4000
B-3720
C4720
D3280
E1220
F5780

Please close this thread by making appropriate answer if you are satisfied...

Regards,

Sub2u

Anonymous
Not applicable
Author

s i agree with that,

my orginal expr looks like

avg(sum(metricvalue)/10000- avg(sum(metricvalue)/10000

in this situtaion  metricvalue  should come

40000 -0  =4000

2800-4000

is your above expression calculate or not ?

SunilChauhan
Champion II
Champion II

Avg(VALUE) - Previous (Avg(VALUE))


or


in script

previous(VALUE) as Previousvalue



andin expression

Avg(VALUE)- avg(Previousvalue )


or


in script

peek(VALUE) as Previousvalue



andin expression

Avg(VALUE)- avg(Previousvalue )


hope this helps

Sunil Chauhan
anbu1984
Master III
Master III

Is this your expected output, else can you post expected output?

146831.png

nikhilgarg
Specialist II
Specialist II

HEy,

You may do like:

Avg(Value) - Avg({<ID = (ID - 1 )>}Value) ;

You may have to look the syntax .