Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for
Did you mean:
Contributor III

## Calculate Differences in a Column

Hello everyone,

I have several orders with a cumulative duration. Now I want to calculate the single duration per step.

I have tried this with

If(Order = previous(Order), Previous(cumulated)-cumulated, 0) as single

Now the single time is shifted by one row.

How do I achieve that it's not shifted anymore?

Thank you very much for your support.

Labels (5)

• ### time difference

2 Replies
Creator II

Hello @rohi__ ,

I don't know if I got it right... See

table:
load order, cumulated, If(order = previous(order), cumulated - previous(cumulated), 0) as single inline [
order, cumulated,
1,0,
1,1,
1,3,
1,6,
1,9,
1,10,
1,208,
2,0,
2,3,
2,6,
2,9,
2,10,
2,167,
3,0,
3,1,
3,1,
3,3,
3,4,
3,11,
3,55
];

Result:

🤔

Contributor III
Author

Hi @Ezir ,

I had to order the data properly...

In the App it showed me the correct sequence but when i looked up the Data Model Viewer it was all messed up.