# QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
cancel
Showing results for
Did you mean:
Highlighted
Contributor III

## Get Max Date and Max Value of a ID

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.

1 Solution

Accepted Solutions
Highlighted
MVP

## Re: Get Max Date and Max Value of a ID

Try this:

Dimension:

ID

Expression:

1) Date(Max(Date))

2) FirstSortedValue(Value, -(Date* 10000 + Value))

7 Replies
Highlighted
MVP

## Re: Get Max Date and Max Value of a ID

Try this:

Dimension:

ID

Expression:

1) Date(Max(Date))

2) FirstSortedValue(Value, -(Date* 10000 + Value))

Highlighted
Contributor III

## Re: Get Max Date and Max Value of a ID

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.

Highlighted
MVP

## Re: Get Max Date and Max Value of a ID

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)

Highlighted
Contributor

## Re: Get Max Date and Max Value of a ID

I had try to see from your source but i cant found anything. Could you kindly help to explain

Highlighted
Contributor III

## Re: Get Max Date and Max Value of a ID

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
Highlighted
Contributor III

## Re: Get Max Date and Max Value of a ID

Check the qvw attached
Highlighted
Partner

## Re: Get Max Date and Max Value of a ID

Hi sunny ,

Again ,if i have to take value of max date form expression 2 , how to do ?