Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
v_jaideep
Creator
Creator

Price based on Min and Max date group by Type and Product

Hi,

How do I find the Price based on Min and Max date which should be group by type and product.

I have a sample data below:

FROM:

TypePriceStart dateProduct
A1001/20/2021ABC
A11112/10/2019ABC
A561/11/2019ABC
B233/20/2021ABC
B2111/3/2020ABC
B4512/25/2019ABC
B891/11/2019ABC
C214/13/2021ABC
C555/31/2020ABC
C871/11/2019ABC

  

TO:

TypeCurrentOldProduct
A10056ABC
B2389ABC
C2187ABC

 

I have used temp and temp1 tables to get min and max start date in the script which are group by type and product but this is taking long time to run ....Is there any other work around to get  the expected data? Can we use firstsortedvalue() for multiple columns in the syntax for ex: firstsortedvalue(distinct price,-start date,Type)

1 Solution

Accepted Solutions
tresesco
MVP
MVP

May be like:

FirstSortedValue( total <Type> Price, -[Start date])

View solution in original post

3 Replies
Dalton_Ruer
Support
Support

=sum(Price*if([Start Date]=aggr(nodistinct max([Start Date]), Type),1,0))

I got it working with that using this post as the guide: https://community.qlik.com/t5/QlikView-App-Dev/Sum-Values-Having-Max-Date/m-p/405311

 

v_jaideep
Creator
Creator
Author

@Dalton_Ruer This does not get me desired result. I wouldn't need sum of all the values for the particular type. I need value of only the max and min date when group by Type.

tresesco
MVP
MVP

May be like:

FirstSortedValue( total <Type> Price, -[Start date])