Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
OrbytaQliker
Contributor II
Contributor II

Date diff with another row

Hi everyone, I have a table in which the data can be aggregated by the fields A and B, as in the following image:

OrbytaQliker_1-1694608787163.png

You can see in this pivot table how the data is aggregated.

my request is calculate the date diff of the field date2 with the previous row (es: i m in the row 3, i should calculate the date diff of field date2 of row 3 and row2), and for  the first item of each aggregated data the date diff between date2 and date1.

I'd accept both the resolution in script and in frontend.

Sorry for my English and thank you very much if you can help me!!

 

Labels (1)
1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi!

This can be done either in the script or in the layout.

In the script, you would need to load your data sorted by all the key fields (A, B, C) and then chronologically by Date, and in the load, you'd use functions Previous() and Peek() to fetch the date from the last record and to verify that the last record belongs to the same set of keys (A, B, C). You can read about this technique in my blog.  

In the layout, you'd need to use the function Above() to fetch the value from the row above.

To learn more advanced development techniques, check out the agenda of the Masters Summit for Qlik - coming soon to Orlando and to Dublin!

View solution in original post

2 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi!

This can be done either in the script or in the layout.

In the script, you would need to load your data sorted by all the key fields (A, B, C) and then chronologically by Date, and in the load, you'd use functions Previous() and Peek() to fetch the date from the last record and to verify that the last record belongs to the same set of keys (A, B, C). You can read about this technique in my blog.  

In the layout, you'd need to use the function Above() to fetch the value from the row above.

To learn more advanced development techniques, check out the agenda of the Masters Summit for Qlik - coming soon to Orlando and to Dublin!

OrbytaQliker
Contributor II
Contributor II
Author

Thank you, your suggestion works well!!!