Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
mamar910
Contributor
Contributor

Nested aggregation not allowed

Hello

I want to count the number of companies that sell the product (1,2,3) ie the amout of sells>0.

I tried  sum(if($(Amount)>0,1,0)), but doesn't work because of nested aggregation.

There'is an example of my data :

 Product 1Product 2Product 3
Company 114144550
Company 201540
Company 3100
Company 401416

Thank's for you're help

2 Replies
agigliotti
Partner - Champion
Partner - Champion

Hi @mamar910 ,

So in your case what should be the expected result?

GaryGiles
Specialist
Specialist

@mamar910 

I'm not sure what is in your variable $(Amount), but I am assuming it is something like sum(Product 1) or sum(Product 2).

To count Companies that sell a particular Product, you could use:

count({$<Company={"=sum([Product 1])>0"}>} Distinct Company)

If you are using a variable to change the product you are looking for, you would need to fit it into this expression.

If the Amount variable contained [Product 1], [Product 2], or [Product 3], it might look like:

count({$<Company={"=sum($(Amount))>0"}>} Distinct Company)