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

Find the Max Date and the corresponding Product per Customer

Hi everyone! Can someone please help me on the following? My data are like the below table:

CustomerDateProduct
CustomerA1/1/2015ProductA
CustomerA1/5/2015ProductB
CustomerB20/5/2015ProductA
CustomerB1/3/2015ProductC
CustomerC10/4/2015ProductB

I need to have per Customer the maximum Date and the corresponding Product. So the result will be like this:

CustomerDateProduct
CustomerA1/5/2015ProductB
CustomerB20/5/2015ProductA
CustomerC10/4/2015ProductB

Any ideas? I would prefer to implement this through Dimensions and expressions and not through the script of my qv document....

9 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Make a table with Customer as dimension and these two expressions:

  • Max(Date)
  • FirstSortedValue(Product, -Date)
Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
PrashantSangle

Hi,

Use FirstSortedValue()

Try like in chart FirstSortedValue(Product,Date)

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Anonymous
Not applicable
Author

Use aggr() function

Siva_Sankar
Master II
Master II

PFA

Not applicable
Author

Hii, Please find the attachment below..

Not applicable
Author

Thank you Jonathan, it works but in some cases it displays the value "-" on column Product. I guess it is because at the same day, it may find two products and don't know which one to choose. Any suggestions?

tresesco
MVP
MVP

Could try like:

FirstSortedValue(Distinct Product, -Date)

Note: Don't worry about the warning at the expression because of this 'distinct' keyword , it works fine.

PrashantSangle

In that case, Which Product you want???

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Not applicable
Author

Thanks guys! Distinct was the solution to my problem! have a nice day!