Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
andreip21
Contributor III
Contributor III

First and second minimum

Hi,

i have the following database:

Product IDPrice StartPrice EndDurationSale Price
11 aug3 aug320
14 aug10 aug715
111 aug11 aug120
112 aug15 aug430
116 aug28 aug1335

how do i get the minimum and the second minimum + duration in this format:

Product IDFirst minDuration First minSecond minDuration Second min
1157204

?

Thanks a lot,

Regards,
Andrei

1 Solution

Accepted Solutions
tresesco
MVP
MVP

You can use set analysis within forstsortedvalue() for the same. PFA

View solution in original post

4 Replies
jyothish8807
Master II
Master II

Hi Andrei,

Please refer the attached.

Br,

KC

Best Regards,
KC
tresesco
MVP
MVP

This might not work for multiple Product IDs. In such cases, you might have to use FirstSortedValue() like in attached.

FirstSortedValue(DISTINCT Aggr(Sum(Duration),[Product ID], [Sale Price]), [Sale Price],2)

andreip21
Contributor III
Contributor III
Author

ok, great, but i have one more question:

can i combine firstsortedvalue with a condition?

let's say, the first and second minimum only after 11 aug.

and the results will be 20 with Duration 1 and 30 with Duration 4.

tresesco
MVP
MVP

You can use set analysis within forstsortedvalue() for the same. PFA