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

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
kbryndum
Partner - Contributor
Partner - Contributor

Help with set expression used with stock level and stock movements

Hi,

Can anyone help me with a set expression, that only shows the value of the max(Date) of a table that consist of the dimension AsOfDate.

The purpose is to show the period movement based on Date, but in the table consisting of AsOfDate dimension and the measure Qty_as_of_date .

I have the period movements for each Date:

Table_1.JPG

I have also Qty for each AsOfDate (stock level):

Table_2.JPG

Now I want to show both measures in the same table, but only with AsOfDate as a dimension. The AsOfDate consist of all dates where Date <= AsOfDate, so for each AsOfDate there is one or more Dates linked to it.

Table_3.JPG

Basically I want to use the Max(Date) for each AsOfDate in a expression like:

sum({$<Date={"$(=max(Date))"}>} TOTAL <[AsOfDate]> Period_QTY)

But this gives only a value for max date of the total application. I need max date used for each record in the table. See attached example.


Any help is much appreciated.

Thanks.

/Kim

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe like

=sum(total<AsOfDate> aggr(if(Date =max(total<AsOfDate> Date), Period_QTY), AsOfDate,Date))

Hope this helps,

Stefan

View solution in original post

4 Replies
swuehl
MVP
MVP

Maybe like

=sum(total<AsOfDate> aggr(if(Date =max(total<AsOfDate> Date), Period_QTY), AsOfDate,Date))

Hope this helps,

Stefan

kbryndum
Partner - Contributor
Partner - Contributor
Author

Great! That's is exactly what I wanted.

I have been looking at creating a set expression, but that might have been the wrong approach.

Thank you so much!

/Kim

swuehl
MVP
MVP

There is even a much simpler expression:

=FirstSortedValue(total<AsOfDate> Period_QTY, -Date)

kbryndum
Partner - Contributor
Partner - Contributor
Author

That's nice, but if I had more dimensions than the date, I can't use it.