Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to count no of occurrences above average

Hello All,

I ran into a scenario , seems to be very simple ask.

Let me start with a scenario , I have group and subgroup and values are for the subgroup. Sample data provided below

GroupSubgroupValue
Group 1SubGroup110
Group 1SubGroup220
Group 1SubGroup330
Group 1SubGroup440
Group 1SubGroup550
Group 2SubGroup6110
Group 2SubGroup7120
Group 2SubGroup8130
Group 2SubGroup9140
Group 2SubGroup10150
Group 2SubGroup11160
Group 2
SubGroup12
170

I would like to build a chart which shows, Group in the dimension, Average for this group "Sum(Value)/count(subgroup)" which is easy. Now the third expression which shows how many subgroups are greater than average.

GroupAverageCount of Subgroups above Average
Group1302
Group21403

Note: Please suggest how can I handle it in the expression directly not in the load script.

Thank you for going over this and giving it a try.

1 Solution

Accepted Solutions
sunny_talwar

You can try this expression for counting:

=Sum(If(Aggr(Value, Group, SubGroup) > Aggr(Avg(TOTAL <Group> Value), Group, SubGroup), 1, 0))

Capture.PNG

View solution in original post

3 Replies
sunny_talwar

You can try this expression for counting:

=Sum(If(Aggr(Value, Group, SubGroup) > Aggr(Avg(TOTAL <Group> Value), Group, SubGroup), 1, 0))

Capture.PNG

Not applicable
Author

Thank you! it worked.

Curious, why TOTAL function on the right side of the comparison operator?

sunny_talwar

Because my aggregate has two dimensions and I need the Avg by just Group.