Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply

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
1 ACCEPTED SOLUTION
V-pazhen-msft
Community Support
Community Support

@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))

 

distinct count, 0.JPG

 

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

View solution in original post

2 REPLIES 2
V-pazhen-msft
Community Support
Community Support

@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))

 

distinct count, 0.JPG

 

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

amitchandak
Super User
Super User

@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))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.