Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
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
Partner - Master

=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 🙂