Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Reliability-Engineer
Contributor III
Contributor III

How to calculate difference of the value between two records in a table

I have several tanks with level measurment. Beside of showing the level in the tank I also want to show the amount of liquid used between two timestamps.

How can I calculate this usage?

With regards

Jan Droog

Reliability-Engineer_0-1593903413130.png

 

1 Solution

Accepted Solutions
Taoufiq_Zarra

Yes!

as you can replace the measure calculated by Column(1) in your case.

look at this example, I replaced the measure (in your case AVG.....)with Column(1)

=if(above(total Datum)=Datum,rangesum(above(total Column(1) )-Column(1)),0)

Capture.PNG

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

6 Replies
Taoufiq_Zarra

Hi,

One solution :

if(previous(Datum)=Datum,previous([LevelAcid Tank (ltr)])-[LevelAcid Tank (ltr)]) as Difference

 

for example for this sample :

load *,if(previous(Datum)=Datum,previous([LevelAcid Tank (ltr)])-[LevelAcid Tank (ltr)]) as Difference  inLine [
Datum,tTimestamp,LevelAcid Tank (ltr)
1,1,905
1,2,881
1,3,856
1,4,829
1,5,803
1,6,777
1,7,751
1,8,724
1,9,699
1,10,686
2,1,1
2,2,10
];

 

the output :

Capture.PNG

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Reliability-Engineer
Contributor III
Contributor III
Author

Taoufiq_ZARRA Thanks for your example.

Got the example working, but I need this calculation in the Expression box.

It that also possible?

Reliability-Engineer_1-1593978693849.png

 

Taoufiq_Zarra

One solution

Dimension :

Datum,tTimestamp,LevelAcid Tank (ltr)

Expression :

=if(above(total Datum)=Datum,rangesum(above(total sum([LevelAcid Tank (ltr)]))-sum([LevelAcid Tank (ltr)])),0)

 

output :

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Reliability-Engineer
Contributor III
Contributor III
Author

Got this one running.

Is it also possible when LevelAcid-Tank is a calculated value?

With regards, Jan

Reliability-Engineer_0-1594062806144.png

 

Taoufiq_Zarra

Yes!

as you can replace the measure calculated by Column(1) in your case.

look at this example, I replaced the measure (in your case AVG.....)with Column(1)

=if(above(total Datum)=Datum,rangesum(above(total Column(1) )-Column(1)),0)

Capture.PNG

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Reliability-Engineer
Contributor III
Contributor III
Author

YES!!  

That's exactly what i needed.  😀

Thank you very much for helping me out.  

Jan Droog