Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Kellerassel
Contributor III
Contributor III

Set Expression: Filter by conditional aggregate

I have data in this shape:

Id metric revenue
1 gross 23
1 net 15
2 gross 45
2 net 12
3 gross 78
3 net 34
4 gross 89
4 net 25

 

What I need is the distinct numbers of Ids where gross revenue is >20 as a chart formula.

Basically this:

 

Count(Distinct {<[Id]={"=Sum({<metric={gross}>} revenue)>=20"} >} Id)

 

 
which doesn't work of course. 

Any help would be greatly appreciated.

Labels (1)
1 Solution

Accepted Solutions
vincent_ardiet_
Specialist
Specialist

The first expression should work and be more performant, what was the issue with it?

View solution in original post

4 Replies
Kellerassel
Contributor III
Contributor III
Author

This does the job using an If()-statement instead of a set expression.

Count(Distinct If(Aggr(Sum({<metric={'gross'}>} revenue), Id) > 20, Id))

 
But maybe there is a more performant solution inside set expression

vincent_ardiet_
Specialist
Specialist

The first expression should work and be more performant, what was the issue with it?

rajjul
Partner - Contributor III
Partner - Contributor III

Not sure why you are using SUM here ...? 

try this whether it works

Count(Distinct{<[revenue]={">20"}>}Id)

Kellerassel
Contributor III
Contributor III
Author

Now I am utterly confused.. Yes, it does work. Now! I have no clue why it didn't work yesterday.