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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Aggr and then count distincts

Hi

I want to calculate a KPI to show the number of orders with total quantity no more than 100 units. However my data is in order line level and needs to be aggregated first. I am assuming a combination of aggr and count distinct but can't really structure the formula.

OrderOrder lineUnits
A150
A240
A320
B120
B210
C18
C240
C320
C43

Thanks in advance

1 Solution

Accepted Solutions
sunny_talwar

May be like this

Sum(Aggr(If(Sum(Units) < 100, 1, 0), Order))

The above should give you 2 (B, C)

View solution in original post

3 Replies
sunny_talwar

May be like this

Sum(Aggr(If(Sum(Units) < 100, 1, 0), Order))

The above should give you 2 (B, C)

Anonymous
Not applicable
Author

Thanks! Can't believe I spent more than an hour for such a simple one!

swuehl
MVP
MVP

Or maybe using set analysis with an advanced search like

=Count({<Order = {"=Sum(Units)<=100"}>} DISTINCT Order)