Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor II
Contributor II

If condition with Aggr in KPI

How to get the below expression in KPI

If(sum( Aggr (CustomerId, Dispense)) = 0, Count(Distinct CustomerId),0). 

The same expression works fine in the table below.  Ideally the result of KPI should be 6 as per the below  highlighted scenario.

 

=Aggr(SUM(Dispense), CustomerId)sum( Total <CustomerName,CustomerId> Dispense)If(sum( Aggr (CustomerId, Dispense)) = 0, Count(Distinct CustomerId),0)=If(Aggr(SUM(Dispense), CustomerId)=0,CustomerId)=Aggr(SUM(Dispense), CustomerId)
00.0E+0001120
00.0E+0001130
00.0E+0001140
00.0E+0001150
00.0E+0001160
00.0E+0001170
1 Solution

Accepted Solutions
Highlighted
Specialist III
Specialist III

Re: If condition with Aggr in KPI

Count(Distinct {<CustomerId={"=Aggr(SUM(Dispense), CustomerId)>0"}>} CustomerId)

Channa

View solution in original post

3 Replies
Highlighted
Employee
Employee

Re: If condition with Aggr in KPI

Try using set analysis for your KPI:

Count({<Dispense={">0"}>}Distinct CustomerId)

Highlighted
Specialist III
Specialist III

Re: If condition with Aggr in KPI

Count(Distinct {<CustomerId={"=Aggr(SUM(Dispense), CustomerId)>0"}>} CustomerId)

Channa

View solution in original post

Highlighted
Contributor II
Contributor II

Re: If condition with Aggr in KPI

@Channa  Thank you.