Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm creating a line chart with month, and count().
count ( distinct Customer_Code)
How can i do the distinct count with IF statement. says count distinct customer if they sales is more than certain amount?
I tried :
if (sum(sales) <> 0 , count ( distinct Customer_Code))
But it's not working. and SET can't do sum() within it. any other alternatives?
Thanks
I would go with:
count(distinct aggr(if(sum(Sales)>100000,CustomerId),CustomerId))
Bro ,
You can try this...........
=
count({$<sum(SalesDetail_Amt) <>{'0'}>} distinct CUSTOMER_ID )
Hi Dushyant,
Thanks for the suggestion. But i think in SET, we can't use functions like sum().
I'm not sure how true, but it doesn't work for me.
hi,
use the aggr function for this:
Count (distinct if(aggr(sum(Sales),CustomerId)>0, CustomerId))
hope this helps.
Thanks, but still not working....
in fact, i need to do <> '0'.
funny thing is, i can get the correct count when i do = '0'
but wrong count for <> ' 0 '
in my data, there are negative values , positive values , and 0.
I'm a bit unsure if the previous aggr-function works, since the aggr will return a data set and not a numeric value. Try adding an additional sum of the aggr to make the result numerical.
Count ( distinct if( sum ( aggr ( sum(Sales), CustomerId) ) >0, CustomerId) )
I would go with:
count(distinct aggr(if(sum(Sales)>100000,CustomerId),CustomerId))