Forum Discussion

dapperscavenger's avatar
6 years ago
Solved

distinct count with filter & sum

Hi!

 

I'm trying to get the number of SKUs where the sum in the value column = 0 :

 

LocationFiscal Year+Month+NameSKUValue
Country A2020-P07-JanProduct A13
Country A2020-P08-FebProduct A0
Country A2020-P09-MarProduct A0
Country B2020-P07-JanProduct A0
Country B2020-P08-FebProduct A0
Country B2020-P09-MarProduct A0
Country B2020-P07-JanProduct B0
Country B2020-P08-FebProduct B7
Country B2020-P09-MarProduct B0
Country A2020-P07-JanProduct C0
Country A2020-P08-FebProduct C0
Country A2020-P09-MarProduct C0
Country C2020-P07-JanProduct B0
Country C2020-P08-FebProduct B4
Country C2020-P09-MarProduct B0

 

I'd like to be able to filter it by the month and the country.  

 

I wrote a formula but it is counting the no of SKUs before summing the values, resulting in some SKU counting as being = 0 and also being >0

 

I'm looking for a way to count the no. of SKUs after the sum.

 

Thank you!

 

Examples based on above table:

How many distinct SKUs with sum of value = 0?
  
ALL1
Filter on country A1
Filter on country B1
Filter on Country C0
Filter on 2020-P08-Feb2
Filter on Country A and 2020-P08-Feb2
Filter on Country B and 2020-P08-Feb1
Filter on 2020-P08-Feb and Product B0
  • Anonymous's avatar
    Anonymous
    6 years ago

    dapperscavenger 

    Measure automatically sums the count. If I understand you currently you could take a look this:

     

    Measure = CALCULATE(DISTINCTCOUNT('Table'[SKU]),FILTER('Table','Table'[Value]=0))

     

     

    Paul Zheng
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • dapperscavenger 

    for count of SKU > 0
    sumx(summarize(Table[product],"_sum",sum(Table[value])),if([_sum]>0,1,0))

    for count of SKU > 0, country wise
    sumx(summarize(Table[product],table[Location],"_sum",sum(Table[value])),if([_sum]>0,1,0))

  • Anonymous's avatar
    Anonymous
    Not applicable

    dapperscavenger 

    Measure automatically sums the count. If I understand you currently you could take a look this:

     

    Measure = CALCULATE(DISTINCTCOUNT('Table'[SKU]),FILTER('Table','Table'[Value]=0))

     

     

    Paul Zheng
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.