Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to get the maximum Date for an item

Dear All,

I have to retrieve values only for the maximum date for each item. HOw can I achieve the same.

DATA

ITEM     DATE                          AMOUNT

A              01-01-2012                    100

A             12-01-2012                     150

A             18-01-2012                     121

B              01-01-2012                    190

B             12-02-2012                     170

B          21-02-2012                        161

Output

ITEM               AMOUNT

A                     121

B                      161

Cheers


1 Solution

Accepted Solutions
swuehl
MVP
MVP

You can use FirstSortedValue():

Create a chart with dimension ITEM and as expression:

=FirstSortedValue(AMOUNT, -DATE)

where DATE needs to have a numerical representation, like all dates created or interpreted by QV.

View solution in original post

4 Replies
swuehl
MVP
MVP

You can use FirstSortedValue():

Create a chart with dimension ITEM and as expression:

=FirstSortedValue(AMOUNT, -DATE)

where DATE needs to have a numerical representation, like all dates created or interpreted by QV.

Not applicable
Author

Hi,

I tried the above code but it doesn't giev a correct figure. I have attach an example.

Let me know where did i went wrong.

swuehl
MVP
MVP

I believe the expression is correct.

It seems that even you've used trim(ITEM) in your load, your ITEM field values are not correctly trimmed to the single characters. 'A' and 'A' are two distinct values (having a length of 34 characters). Maybe some hard spaces.

Try

trim(purgechar(ITEM, chr(160))) as ITEM

in your load.

Hope this helps,

Stefan

Not applicable
Author

HI,

thanks buddy..!! I will try it my scenario and keep you updated on the same.