Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
microwin88x
Creator III
Creator III

Get Contract for Max Date

Hello,

I have the following table (DATE_CON has format: DD/MM/YYYY):

MALLUNITBRANDDATE_CONCONTRACT
MALL1UNIT01BRAND101/04/201735
MALL1UNIT01BRAND101/05/201735
MALL1UNIT01BRAND101/06/201735
MALL1UNIT01BRAND101/07/201735
MALL1UNIT01BRAND101/08/201735
MALL1UNIT01BRAND101/09/201735
MALL1UNIT01BRAND101/10/201735
MALL1UNIT01BRAND101/11/201735
MALL1UNIT01BRAND101/12/201735
MALL1UNIT11BRAND101/12/201790
MALL2UNIT02BRAND101/06/201733
MALL2UNIT02BRAND101/07/201733
MALL2UNIT02BRAND101/08/201733
MALL2UNIT02BRAND101/09/201733
MALL2UNIT02BRAND101/10/201733
MALL2UNIT02BRAND101/11/201733
MALL2UNIT02BRAND101/12/201733
MALL3UNIT03BRAND101/03/201742
MALL3UNIT03BRAND101/04/201742
MALL3UNIT03BRAND101/05/201742
MALL3UNIT03BRAND101/06/201742
MALL3UNIT03BRAND101/07/201742
MALL3UNIT03BRAND101/08/201742
MALL3UNIT03BRAND101/09/201742
MALL3UNIT03BRAND101/10/201742
MALL3UNIT03BRAND101/11/201742
MALL3UNIT03BRAND101/12/201742
MALL3UNIT33BRAND101/12/201748
MALL4UNIT04BRAND101/02/201777
MALL4UNIT04BRAND101/03/201777
MALL4UNIT04BRAND101/04/201777
MALL4UNIT04BRAND101/05/201777
MALL4UNIT04BRAND101/06/201777
MALL4UNIT04BRAND101/07/201777
MALL4UNIT04BRAND101/08/201777
MALL4UNIT04BRAND101/09/201777
MALL4UNIT04BRAND101/10/201777
MALL4UNIT04BRAND101/11/201777
MALL4UNIT04BRAND101/12/201777
MALL5UNIT05BRAND101/02/201765
MALL5UNIT05BRAND101/03/201765
MALL5UNIT05BRAND101/04/201765
MALL5UNIT05BRAND101/05/201765
MALL5UNIT05BRAND101/06/201765
MALL5UNIT05BRAND101/07/201765
MALL5UNIT05BRAND101/08/201765
MALL5UNIT05BRAND101/09/201765
MALL5UNIT05BRAND101/10/201765
MALL5UNIT05BRAND101/11/201765
MALL5UNIT05BRAND101/12/201765
MALL6UNIT06BRAND101/04/201714
MALL6UNIT06BRAND101/05/201714
MALL6UNIT06BRAND101/06/201714
MALL6UNIT06BRAND101/07/201714
MALL6UNIT06BRAND101/08/201714
MALL6UNIT06BRAND101/09/201714
MALL6UNIT06BRAND101/10/201714
MALL6UNIT06BRAND101/11/201714
MALL6UNIT06BRAND101/12/201714
MALL7UNIT07BRAND101/07/201739
MALL7UNIT07BRAND101/08/201739
MALL7UNIT07BRAND101/09/201739
MALL7UNIT07BRAND101/10/201739
MALL7UNIT07BRAND101/11/201739
MALL7UNIT07BRAND101/12/201739
MALL8UNIT08BRAND101/08/201752
MALL8UNIT08BRAND101/09/201752
MALL8UNIT08BRAND101/10/201752
MALL8UNIT08BRAND101/11/201752
MALL8UNIT08BRAND101/12/201752
MALL9UNIT09BRAND101/04/201587
MALL9UNIT09BRAND101/05/201587
MALL9UNIT09BRAND101/06/201587
MALL9UNIT09BRAND101/07/201587
MALL9UNIT09BRAND101/08/201587
MALL9UNIT09BRAND101/09/201587
MALL10UNIT10BRAND101/12/201025
MALL10UNIT10BRAND101/01/201125
MALL10UNIT10BRAND101/02/201125
MALL10UNIT10BRAND101/03/201125
MALL10UNIT10BRAND101/04/201125
MALL10UNIT10BRAND101/05/201125

What I need is to get the last Contract (getting the Max Date) for every Mall and Unit.

Note that there could be more than 1 Unit for a Mall for a Max Date, like Mall 1 or Mall 3.

I should get the following:

MALLUNITBRANDDATE_CONCONTRACT
MALL1UNIT01BRAND101/12/201735
MALL1UNIT11BRAND101/12/201790
MALL2UNIT02BRAND101/12/201733
MALL3UNIT03BRAND101/12/201742
MALL3UNIT33BRAND101/12/201748
MALL4UNIT04BRAND101/12/201777
MALL5UNIT05BRAND101/12/201765
MALL6UNIT06BRAND101/12/201714
MALL7UNIT07BRAND101/12/201739
MALL8UNIT08BRAND101/12/201752
MALL9UNIT09BRAND101/09/201587
MALL10UNIT10BRAND101/05/201125

Do you know how could I do that? I'd need to do this as an expression for a Pivot Table.

Thank you!!!

6 Replies
YoussefBelloum
Champion
Champion

Hi,

just use Date(Max(date_field))

see attached

Anil_Babu_Samineni

Just use this expression in pivot table

Sum({<DATE_CON = {'$(=Date(Max(DATE_CON)))'}>} CONTRACT)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
tresesco
MVP
MVP

Exp1=Date(Max(DATE_CON))

Exp2=FirstSortedValue(CONTRACT, -DATE_CON)

Capture.JPG

microwin88x
Creator III
Creator III
Author

Hello Anil,

I've tried this, but the problem is that it doesn't shows Malls 9 and 10 in the table.

I believe that happens because Malls 1 to 8 have DATE_CON = 01/12/2017 and Mall 9 has 01/09/2015 and Mall 10 has 01/05/2011.


Do you know how could I fix it?


Thanks!

microwin88x
Creator III
Creator III
Author

Hello Tresesco,

Is there any way to use a single expression instead of two? Because I wouldn't really need to show the date.

Thanks!

tresesco
MVP
MVP

Just omit the first expression. Second expression is not at all dependent on first, because it's not a dimension.