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

Use of aggregations within a dimension

Hi all,

I have the following scenario:

CategoryNumSales
A7102
A9101
A10103
A16100
B6105
B8106
B15104
B20107
C25108
C27109
C28110
C30111
D5120
D12115
D13116
D23114
D45113

And I am trying to get the following result:

CategorySales of MIN(Num) Other ExpressionsOthe Expressions
A102
B105
C108
D120

Which is the Sum of Sales for each category when Num is the minimum for that category.

I have tried all possible aggregations by Category and Set Analysis. None worked.

Note:

Having the Num field as a dimension is not an option. In addition, it is a must that the solution allows other expressions besides the one I am requesting help for.

The following expression works fine having Num as dimension, "Show zero values" checked and with only one expression in the chart, but as said that is not suitable for my scenario:


IF ( Num = AGGR(NODISTINCT MIN(Num), Category) ,SUM(Sales) )


Any ideas?

Thank you.

1 Solution

Accepted Solutions
sunny_talwar

Try this expression:

=FirstSortedValue(Sales, Num)


Capture.PNG

View solution in original post

10 Replies
sunny_talwar

Try this expression:

=FirstSortedValue(Sales, Num)


Capture.PNG

sunny_talwar

Or this:

=FirstSortedValue(Aggr(Sum(Sales), Num, Category), Aggr(Num, Num, Category))

UPDATE: If you can have multiple sales value per Num.

UPDATE2: Further updated the expression to make sure it gives the correct output in all cases

Anonymous
Not applicable

Hi

have you tried this ?

RANGEMIN(ABOVE(SUM((Sales)),0,RowNo(TOTAL))) 


or

aggr(RANGEMIN(ABOVE(SUM((Sales)),0,RowNo(TOTAL))),Category)



luis_pimentel
Partner - Creator III
Partner - Creator III
Author

Wow.... I am shocked how simple it is. I have used FirstSortedValue before but didn't realize this time.

Thank you!

sunny_talwar

May be look here to learn when you might need to use FirstSortedValue

Value Associated with Min/Max Value of Another Field (Front End Solution)

luis_pimentel
Partner - Creator III
Partner - Creator III
Author

Actually, having multiple sales value per Num, this expression is not working (null returned)

Yes!

sunny_talwar

I updated my expression, can you check if this is working:

=FirstSortedValue(Aggr(Sum(Sales), Num, Category), Aggr(Num, Num, Category))

luis_pimentel
Partner - Creator III
Partner - Creator III
Author

Yes, perfectly!

Many thanks

sunny_talwar

The new updated expression worked out?