Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Ceb
Contributor III
Contributor III

Sum of an If condition

Hi,

 

I am trying to sum the following the if condition but I am getting error in expression.

=sum(if(

(count({<[Status]={'Satisfied'}>} [Status])/Count([Status]))
-
max(target)

> 0 ,1,0
))

 

Do I need to use aggregate function for this? 

I did go through some posts and it showed sum and if works together but it wasn't for set analysis so I am not sure

Labels (3)
3 Replies
sunny_talwar

Which dimension/s are you checking this condition against?

if(

(count({<[Status]={'Satisfied'}>} [Status])/Count([Status]))
-
max(target)

> 0

Ceb
Contributor III
Contributor III
Author

Thank you for the reply Sunny.

 

So I have 2 tables and both of them are connected by 3 dimensions

The main table has 4 columns Region, Company, Type, Status(satisfied, negative, neutral)

The target table has the same first 3 columns and the last column is the Target

I have joined these 2 tables using the 3 common columns

Now I am trying to compare the total count of status(satisfied) and the target and then sum the total which have crossed the target. All of these aggregated by Region->Company->Type

sunny_talwar

May be this

=Sum(Aggr(
  If((Count({<[Status] = {'Satisfied'}>} [Status])/Count([Status]))-Max(target)> 0, 1, 0)
, Region, Company, Type))