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

IF Expression Based on Most Recent Date

I have a table of data that appears as such:

priceSTRUCTUREID         Price            PriceCODE            Date (mm/dd/yyyy)

1234                                        55                a                                   2/1/2019

1234                                        60                a                                   2/15/2019

1234                                       40                 a                                   2/20/2019

 

I want to build an expression that would generate the result for 'Price' based on the most recent date, which in this case would be 40

13 Replies
sunny_talwar

May be this

FirstSortedValue(Price, -Date)
EvanBarrick
Creator
Creator
Author

This expression will be placed in a table. The Dimension is 'PRICECODE'

When I enter your expression, no output is generated

sunny_talwar

With the sample data you have provided, I don't see why the expression I have provided won't work. I am sure something else which you might not have shared in the sample data might be causing this. Can you share a better sample data?

EvanBarrick
Creator
Creator
Author

STRUCTUREID                   PRICE                 DATE                  CODE

11065                                       85                     12/29/2015         100PRF

11069                                      100                   01/14/2019          CLUB

11069                                      20                      01/14/2019          300LV3

11069                                      55                      12/20/2018           100LV3

11064                                      60                       12/31/2018           100LV4

11072                                      20                         01/02/2019        300LV5

11059                                      25                       11/03/2108          300LV3

EvanBarrick
Creator
Creator
Author

PRICESTRUCTUREID              PRICE          DATE                          CODE

11065                                           85                   12/29/2018             100PRF

11069                                           100                 01/14/2019             CLUB

11069                                             20                   12/20/2018            300LV3

11069                                             55                    12/31/2018           100LV3

11064                                              60                  01/02/2019             100LV4

11072                                              20                 11/03/2018               300LV5

11059                                              25                 01/02/2019                 300LV3

EvanBarrick
Creator
Creator
Author

I attempted to respond with more data, but it was marked as spam

sunny_talwar

Post it as an Excel file

EvanBarrick
Creator
Creator
Author

 
sunny_talwar

So, Code is the dimension here and you would want something like this

Code        Price
100LV3     60
300LV2     75
100LV2     155
CLUB         80
100PRF     90

My expression still holds

FirstSortedValue(Price, -Date)