Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
microwin88x
Creator III
Creator III

Get Value for a Max Date

Hello,

I have the following table:

Note: The Date has format DD/MM/YYYY

STOREUNITDATENAMECONTR
ST 1UNT101/08/2017CLI15565
ST 1UNT101/09/2017CLI15566
ST 1UNT101/10/2017CLI15567
ST 1UNT101/11/2017CLI15568
ST 1UNT101/12/2017CLI15569
ST 1UNT1101/12/2017CLI16569
ST 2UNT201/01/2017CLI15570
ST 2UNT201/02/2017CLI15571
ST 2UNT201/03/2017CLI15572
ST 2UNT201/04/2017CLI15573
ST 2UNT201/10/2017CLI15579
ST 2UNT201/11/2017CLI15580
ST 2UNT201/12/2017CLI15581
ST 3UNT301/01/2017CLI15582
ST 3UNT301/02/2017CLI15583
ST 3UNT301/11/2017CLI15592
ST 3UNT301/12/2017CLI15593
ST 4UNT401/10/2017CLI15603
ST 4UNT401/11/2017CLI15604
ST 4UNT401/12/2017CLI15605
ST 5UNT501/01/2017CLI15606
ST 5UNT501/02/2017CLI15607
ST 5UNT501/03/2017CLI15608
ST 5UNT501/11/2017CLI15616
ST 5UNT501/12/2017CLI15617
ST 6UNT601/01/2017CLI15618
ST 6UNT601/10/2017CLI15627
ST 6UNT601/11/2017CLI15628
ST 6UNT601/12/2017CLI15629
ST 7UNT701/01/2017CLI15630
ST 7UNT701/02/2017CLI15631
ST 7UNT701/11/2017CLI15640
ST 7UNT701/12/2017CLI15641

What I need is to get the Contract for the max Date by Store and Unit.

Please, note that a Store could have more than 1 Unit for the max Date (for example, with ST 1).

I should get something like this:

STOREUNITDATENAMECONTR
ST 1UNT101/12/2017CLI15569
ST 1UNT1101/12/2017CLI16569
ST 2UNT201/12/2017CLI15581
ST 3UNT301/12/2017CLI15593
ST 4UNT401/12/2017CLI15605
ST 5UNT501/12/2017CLI15617
ST 6UNT601/12/2017CLI15629
ST 7UNT701/12/2017CLI15641

Do you know how could I do that on a chart expression?

My dimensions should be Store and Unit, and my expression the last Contract.

Thank you!!!

1 Solution

Accepted Solutions
pradosh_thakur
Master II
Master II

sum({<DATE={"=(DATE=Max(TOTAL <STORE,UNIT>DATE))"}>}CONTR)

Learning never stops.

View solution in original post

5 Replies
vishsaggi
Champion III
Champion III

May be this? Add additional dimensions accordingly.

Dim: Store, UNIT

Expr:

= FirstSortedValue(CONTR, -Aggr(CONTR, STORE, UNIT, CONTR))

pradosh_thakur
Master II
Master II

Try this

Capture.PNG

Learning never stops.
microwin88x
Creator III
Creator III
Author

Hi Vishwarath,

Do I have to put the Date somewhere? How does it knows which is the last contract?

Thanks!

pradosh_thakur
Master II
Master II

sum({<DATE={"=(DATE=Max(TOTAL <STORE,UNIT>DATE))"}>}CONTR)

Learning never stops.
vishsaggi
Champion III
Champion III

Just use another FirstSortedValue like

= Date(FirstSortedValue(DATE, -Aggr(CONTR, STORE, UNIT, CONTR)))