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

FirstSortedValue

Dimension

PartNumber

Expression

FirstSortedValue(Price,-InvoiceDate)

1) Giving me '-' whenever same part number is sold more than once on the same date.

2) What if same part number is sold more than once with different price

My Idea is to get Minimum Price for each part number sold on the latest Date...

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

How about:


=FirstSortedValue(DISTINCT Aggr(Min(Price),PartNumber,InvoiceDate),-InvoiceDate)


-Rob

View solution in original post

14 Replies
hic
Former Employee
Former Employee

Try

     FirstSortedValue(Aggr(Min(Price),PartNumber,InvoiceDate),-InvoiceDate)

HIC

MK_QSL
MVP
MVP
Author

Hi Henric,

Its not working...

Please check enclosed file..

hic
Former Employee
Former Employee

You can do it using a cross-table and the Above() function.

LastPrice = If(IsNull(Min(Price)),Above(LastPrice),Min(Price))

LastPrice.png

MK_QSL
MVP
MVP
Author

Dear Henric,

Thanks for your valuable time but this will not work for me...

I have around 80,000 part numbers...

The preferable solution should be as per below table.

PartNumberMinPriceMaxInvoiceDate
A10508/01/2014
B11004/01/2014
C13010/01/2014
D11007/01/2014
MK_QSL
MVP
MVP
Author

Any reply on this?

Your help would be highly appreciated...

jerem1234
Specialist II
Specialist II

This might not be the most elegant, but you could sort using the concat function. Try this out:

subfield(concat(aggr(min(Price), PartNumber, InvoiceDate), '|', -InvoiceDate), '|', 1)

Hope this helps!

MK_QSL
MVP
MVP
Author

Tricky and working but still would love to get another way.

whiteline
Master II
Master II

Hi.

This will give you the result:

=FirstSortedValue(Aggr(Min(Price),PartNumber,InvoiceDate),-aggr(InvoiceDate, PartNumber, InvoiceDate))

Not applicable

Hi,

Here is my suggestion:

=Min(if(InvoiceDate=aggr(NODISTINCT Max(InvoiceDate), PartNumber),  Price))