Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
It's possible to get a max value of a max date of one ID using expressions in QlikView?
Table:
ID | Date | Value |
1 | 01/01/2016 | 10 |
1 | 01/01/2016 | 15 |
1 | 02/01/2016 | 5 |
1 | 02/01/2016 | 8 |
2 | 05/01/2016 | 25 |
2 | 05/01/2016 | 4 |
2 | 07/01/2016 | 19 |
2 | 07/01/2016 | 15 |
Result:
ID | Max Date | Max Value |
1 | 02/01/2016 | 8 |
2 | 07/01/2016 | 19 |
Best Regards.
Try this:
Dimension:
ID
Expression:
1) Date(Max(Date))
2) FirstSortedValue(Value, -(Date* 10000 + Value))
Try this:
Dimension:
ID
Expression:
1) Date(Max(Date))
2) FirstSortedValue(Value, -(Date* 10000 + Value))
Hi Sunny,
Great solution .. However I didn't understand, in the FirstSortedValue function, why would we need to use (Date*1000+Value) as sort weight .. I was assuming it would sort just by using 'Date' here.
Could you please explain this logic.. I am quite confused.
Trying to sort just based on date will give you two max values for each ID. But we want the max value for max date. This is double sorting, which isn't available within FirstSortedValue. So in order to do double sorting, we are trying to sort based on Date 1st (mutiplying is by 10000 to give it higher wait) and second by Value itself (multiplying by 1 to give it lower weight)
I had try to see from your source but i cant found anything. Could you kindly help to explain
Thanks in advance
I have a similar question. I am trying to create a calculated dimension in which I need to consider (distinct max date and distinct Name_String) ?
Name_String | date | output_string |
string1 | date1 | string1_yyw3 |
string1 | date3 | string1_yyw2 |
string1 | date3 | string1_yyw1 |
string2 | date1 | string2_yyw1 |
string2 | date3 | string2_yyw2 |
string2 | date3 | string2_yyw3 |
Hi @sunny_talwar i Used this solution, it is working fine for most of the IDs But i am getting Null in some case as as shown below
For Example:
Date | Time | ID | Value |
1/12/2021 | 1:51:35 PM | 101 | 1 |
1/12/2021 | 10:13:33 PM | 101 | 2 |
1/12/2021 | 10:13:34 PM | 101 | 2 |
It should return value 2 with time 10:13:34 as it is the max value but its showing null, i think the function cannot able to identify which one is higher because 2 values are same.
Kindly advise