Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

montubhardwaj
Valued Contributor

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

Re: Max Value for latest and previous date

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)

3 Replies
montubhardwaj
Valued Contributor

Re: Max Value for latest and previous date

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

Re: Max Value for latest and previous date

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
Valued Contributor

Re: Max Value for latest and previous date

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