
Contributor II
2020-08-02
10:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sum Aggr and Count with Multiple If Else Conditions
Good Day All,
I am working on store related data and i have to calculate compliance on each visit for a KPI but the problem is we have different store types with different criteria applied on it.
I have write below expression but there is some mistake in it, can you please help me out where i am making the mistake.
Expression:
sum(aggr(
If(count
(distinct
if
(Parameter='KPI-1' and Compliance='C' and Store_Type<>'Cosmetics',Category)
)>=5,1,if(Parameter='KPI-1' and Compliance='C' and Store_Type='Cosmetics',Category)>=2,1)
,Visit,Compliance))
Criteria:
Grocers =5, Cosmetics=2
1,720 Views
1 Solution
Accepted Solutions

MVP
2020-08-04
12:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can try below
sum(aggr(if(Count({<Parameter={'KPI-1'},Compliance={'C'},Store_Type={'Grocers'}>}Visit)>=5,1),Store_Type,Compliance,Visit))+
sum(aggr(if(Count({<Parameter={'KPI-1'},Compliance={'C'},Store_Type={'Cosmetics'}>}Visit)>=2,1),Store_Type,Compliance,Visit))
3 Replies

MVP
2020-08-02
10:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How you are getting total visit as 4?

Contributor II
2020-08-02
11:51 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For Total Visits:
=Sum( Aggr(Count(DISTINCT if(Parameter='KPI-1', Visit)), Storecode))
1,687 Views

MVP
2020-08-04
12:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can try below
sum(aggr(if(Count({<Parameter={'KPI-1'},Compliance={'C'},Store_Type={'Grocers'}>}Visit)>=5,1),Store_Type,Compliance,Visit))+
sum(aggr(if(Count({<Parameter={'KPI-1'},Compliance={'C'},Store_Type={'Cosmetics'}>}Visit)>=2,1),Store_Type,Compliance,Visit))
