Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Most common value in chart expression

Hi all, I'm a bit stuck with a chart expression. I want to show the most common branch that a customer has purchased from. If I select a specific customer account number (this is my dimension) then this expression works fine, but It will not work if I don't select a customer

firstsortedvalue(UNIT.BRANCH_NAME, -Aggr(count(UNIT.TOTALSOLD), UNIT.BRANCH_NAME),1)

I'd be very grateful for any help, thanks, Simon

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Not really what you want to achieve, could you upload a small sample QVW or describe your chart and data a bit more detailed.

Try also adding the chart dimension to your aggr() dimensions:

firstsortedvalue(UNIT.BRANCH_NAME, -Aggr(count(UNIT.TOTALSOLD),Customer, UNIT.BRANCH_NAME),1)

View solution in original post

5 Replies
swuehl
MVP
MVP

Maybe something like

=Mode( aggr(

firstsortedvalue(UNIT.BRANCH_NAME, -Aggr(count(UNIT.TOTALSOLD),UNIT.BRANCH_NAME),1)

,[Customer account])

)

Not applicable
Author

Hi swuehl, thanks for your reply, unfortunately that returns null values too

swuehl
MVP
MVP

Not really what you want to achieve, could you upload a small sample QVW or describe your chart and data a bit more detailed.

Try also adding the chart dimension to your aggr() dimensions:

firstsortedvalue(UNIT.BRANCH_NAME, -Aggr(count(UNIT.TOTALSOLD),Customer, UNIT.BRANCH_NAME),1)

swuehl
MVP
MVP

I think you might run into issues when you don't have a single #1 branch per customer, a situation where QV's FirstSortedValue() function will return NULL.


You can try to break the ties by manipulating the sort order.


Have a look at this sample to see what I mean (you'll need to reload some times to see the ties showing up).

Not applicable
Author

Hi swuehl, adding chart dimension fixed this, many thanks