Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
mkb_Qlik
Contributor III
Contributor III

Subtracting values in Same column - Current to previous row

Hello,

I have a table like below,

clipboard_image_0.png

 

I need the results  as like below snapshot,

clipboard_image_2.png

 

How to accomplish this in Qlik Load Script

 

 

Labels (2)
1 Solution

Accepted Solutions
Quy_Nguyen
Specialist
Specialist

Try this:

If(isNull(Above(Sum(Value))) or (field <> Above(field)),Sum(Value),Sum(Value) - Above(Sum(Value)))

View solution in original post

6 Replies
asinha1991
Creator III
Creator III

RESULTTBL:

Load VALUE- if(isnull(previous(VALUE),0,previous(VALUE)) as RESULT

Resident Temp;

Ksrinivasan
Specialist
Specialist

Hi,

If(ID='1',0,VALUE-Above(VALUE))

You can try this.

 

K. Srinivasan

 

mkb_Qlik
Contributor III
Contributor III
Author

Hello Thanks for your response.

 

How we can accomplish this as Measure expression. For example my data looks like below

 

Load * inline

[

id value

1, 100

1,20

2,30

3,40];

Quy_Nguyen
Specialist
Specialist

In the dashboard, create a table:

+ Dimension: id

+ Measure 1: Sum(value)

+ Measure 2:  If(isNull(Above(Sum(value))), Sum(value), Sum(value) - Above(Sum(value)))

Is this what you expected:

clipboard_image_0.png

 

mkb_Qlik
Contributor III
Contributor III
Author

Hello,

Thanks for the example, In case if i have multiple dimensions, how to handle it. For example refer below data.

 

Load * Inline

[

field, ID,Value

A,1,120

A,2,30

B,1,120

B,2,45

C,1,456

D,2,50];

Quy_Nguyen
Specialist
Specialist

Try this:

If(isNull(Above(Sum(Value))) or (field <> Above(field)),Sum(Value),Sum(Value) - Above(Sum(Value)))