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

Announcements
Q&A with Qlik - Qlik Cloud Migration: Questions about migrating to Qlik Cloud? Catch the latest replay!
cancel
Showing results for 
Search instead for 
Did you mean: 
Hauglaen
Contributor II
Contributor II

FirstSortedValue on Max date

Hi

My dataset consist of a weekly report showing sales and inventory.

And I am having trouble displaying inventory for only the last week.

 

My current solution displays the latest inventory update for each ID and not only for the last week:

ALT(FirstSortedValue(Inventory,-Date),0)

 

Any suggestions? 

Thanks!

1 Solution

Accepted Solutions
Hauglaen
Contributor II
Contributor II
Author

Your expression didnt work, but it sent me on the right path.

 

The following expression worked for me:

SUM( IF( Date = MAX(TOTAL Date), Inventory, 0 ))

 

Thank you!

View solution in original post

6 Replies
agigliotti
MVP
MVP

could you explain better what are you trying to achieve?
what is your current result and what is your desired result?

The Power of shining a light on the dark side of your data.
Follow me on my LinkedIn | Know Gamma Informatica at gammainformatica.it
Hauglaen
Contributor II
Contributor II
Author

My dataset looks like this:

IDInventoryDate 
12026.04.2020
21026.04.2020
31526.04.2020
11003.05.2020
21503.05.2020

 

And I only want to see the latest inventory update:

IDInventoryDate
11003.05.2020
21503.05.2020

 

My current solution includes 15 from ID 3 because its the latest value for the ID.

agigliotti
MVP
MVP

you case use the below expression:

sum( {< Date = {"$(=date(max(Date)))"} >}Inventory)

with Date and ID as dimensions.

The Power of shining a light on the dark side of your data.
Follow me on my LinkedIn | Know Gamma Informatica at gammainformatica.it
Hauglaen
Contributor II
Contributor II
Author

Your expression didnt work, but it sent me on the right path.

 

The following expression worked for me:

SUM( IF( Date = MAX(TOTAL Date), Inventory, 0 ))

 

Thank you!

agigliotti
MVP
MVP

please close this thread and mark the reply as solution if applicable.

The Power of shining a light on the dark side of your data.
Follow me on my LinkedIn | Know Gamma Informatica at gammainformatica.it
Hauglaen
Contributor II
Contributor II
Author

I tried sum( {< Date = {"$(=date(max( TOTAL Date)))"} >}Inventory)

But it just resulted in zeroes for each ID.