Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
chloe
Contributor III
Contributor III

Set analysis or if statement

Hi,

 

I need to calculate -> count distinct of order_id but only when the count of order_id is >= 2.

This calculation should be on KPI object. 

I tried -

if(count(ORDER_ID)>= 2 , count(distinct SHOPIFY_ORDER_ID))

When I tried it in "table" it worked but on KPI it didn't.

Would appreciate your help.

 

Thanks.

Labels (2)
1 Solution

Accepted Solutions
Digvijay_Singh

 if @BrunPierre expression troubles due to nested aggregation, you may try adding Aggr in between, but cannot be sure without testing

=Count(DISTINCT Aggr( If(Count(ORDER_ID)>= 2, SHOPIFY_ORDER_ID),SHOPIFY_ORDER_ID))

View solution in original post

3 Replies
BrunPierre
Partner - Master II
Partner - Master II

=Count(DISTINCT If(Count(ORDER_ID)>= 2, SHOPIFY_ORDER_ID))

Digvijay_Singh

 if @BrunPierre expression troubles due to nested aggregation, you may try adding Aggr in between, but cannot be sure without testing

=Count(DISTINCT Aggr( If(Count(ORDER_ID)>= 2, SHOPIFY_ORDER_ID),SHOPIFY_ORDER_ID))

chloe
Contributor III
Contributor III
Author

It worked! 

Thank you 🙂