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

Max Value for latest and previous date

Hello,
I am looking for your suggestions on how to achieve this in QlikView. I want to display current value and previous value 'Factor' in a two different text objects. For example, in the example,

- for product C, the latest date is 01/25/2019 and there are two value 0.51 and 0.82 for this. I want to display 0.82 in 1st text object (i.e. max of value if there are same dates). In 2nd text object, I want to display previous value for Product C on earlier date i.e. the value which was on 1/24/2019, which is 0.47

Similarly, For product B, first text object I want to show 0.65 (i.e. max of value if there are same dates). And for Product B, in the 2nd text object,I want to display 0.58 (Max value for the same dates just before the latest date).

How can I achieve this? I have attached the sample qvw for your reference.

1 Solution

Accepted Solutions
rubenmarin

Hi, if one product has to be selected:
1st: =Max({<Date={"$(=date(Max(Date)))"}>} Factor)
2nd: =Max({<Date={"$(=date(Max(Date,2)))"}>} Factor)

For fixed product in expression:
2nd: =Max({<Product={'Product_B'}, Date={"$(=date(Max({<Product={'Product_B'}>} Date,2)))"}>} Factor)

View solution in original post

3 Replies
montubhardwaj
Specialist
Specialist
Author

Is this something we can achieve by FirstSortedValue? Looking for some suggestions here.

rubenmarin

Hi, if one product has to be selected:
1st: =Max({<Date={"$(=date(Max(Date)))"}>} Factor)
2nd: =Max({<Date={"$(=date(Max(Date,2)))"}>} Factor)

For fixed product in expression:
2nd: =Max({<Product={'Product_B'}, Date={"$(=date(Max({<Product={'Product_B'}>} Date,2)))"}>} Factor)

montubhardwaj
Specialist
Specialist
Author

This is sweet and easy. Thanks a ton for suggestion @rubenmarin