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...

14 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

How about:


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


-Rob

whiteline
Master II
Master II

It works, but I don't understand why

MK_QSL
MVP
MVP
Author

So after a very hard and tired day, I got some useful solutions.

Jerem

SubField(CONCAT(Aggr(MIN(Price),PartNumber,InvoiceDate),'|',-InvoiceDate),'|',1)

B Aydin

Min(If(InvoiceDate = Aggr(NODISTINCT Max(InvoiceDate), PartNumber), Price))

Would appreciate if you explain to understand the use of NODISTINCT in this expression...

Rob

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

Hi Rob, What is the reason of getting syntex error (red lines) in expression?

Whiteline

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

Can anyone try to explain how above expression is working? Want to understand the magic behind two InvoiceDate in single Aggr.

Thanks all for your support.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

"... Hi Rob, What is the reason of getting syntax error (red lines) in expression?"

DISTINCT appeared in the doc some time back (I think an early QV10 SR) but the syntax checker was never updated. (or may have worked for a while -- can't recall). The red squiggle is probably why most people don't know about DISTINCT in FirstSortedValue . Welcome to the club.

-Rob

MK_QSL
MVP
MVP
Author

Thanks ROB....