Forum Discussion

LinhDO's avatar
LinhDO
Frequent Visitor
6 years ago

Count distinct customers having sales

Hi everyone,

 I m new to Power BI and struggling with Power BI DAX.

I'm trying to count Distinct customers having sales. It means when selecting relevant months, only customers having sales will be counted. 

I used the following measure:

"CALCULATE(DISTINCTCOUNT(Rawdata[cust code]),
FILTER(Rawdata, CALCULATE(SUM(Rawdata[f_Value]),
ALLEXCEPT(Rawdata,Rawdata[cust code]))>0))"
Error: It does not work with the condition "having sales > 0". For example, I select Oct 2019, it counts all distinct customers, including customers having sales < 0. I think the Filter function does not work, it just summerize the sales of customers of any time, not based on the months that I selected (ex Oct'19).
 
Hope that you can help me on this issue.
Thanks a lot in advance!

 

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    LinhDO Please use this measure. In case this is not what you expected, share some dummy data along with expected result

     Measure = CALCULATE(DISTINCTCOUNT('Table'[cust code]),FILTER('Table','Table'[f_value]>0))