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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
michal
Partner - Contributor III
Partner - Contributor III

sum of last available prices with set analysis and aggregation

Hello Guys.

I have a set of data with products, prices and dates of these prices.

I want to sum prices of all products, but only last available prices.

Could you help create a working expression for that?

PRODUCTPRICEDATE OF PRICE
A1112014-10-20
A1102014-10-21
A192014-10-22
A2122014-10-23
A2132014-10-24
A2142014-10-25

The result here should be 23: 9 (for product A1) + 14 (for product A2) = 23.

1 Solution

Accepted Solutions
Anonymous
Not applicable

Try this:

=sum(aggr(if(max(TOTAL <PRODUCT> [DATE OF PRICE])=[DATE OF PRICE], sum(PRICE)), PRODUCT, [DATE OF PRICE]))

Capture.PNG.png

View solution in original post

3 Replies
Anonymous
Not applicable

Try this:

=sum(aggr(if(max(TOTAL <PRODUCT> [DATE OF PRICE])=[DATE OF PRICE], sum(PRICE)), PRODUCT, [DATE OF PRICE]))

Capture.PNG.png

jaimeaguilar
Partner - Specialist II
Partner - Specialist II

Hi,

you may resolve this with aggr and firstsortedvalue,

check the attached example,

regards

gartigas
Contributor II
Contributor II

I think you can use this:

FirstSortedValue (PRICE,-DATE_OF_PRICE) as LAST_PRICE,

The minus sign (before Date o f Price) is due to the fact that you want the "Last Value".

There is not a "LastSortedValue" function.

Regards

Gustavo