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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Distinct count based on criteria from another column

Hello,

 

My data table looks like the below. "Result" is a measure that I created from other measures/fields. 

Store IDSurvey DateResult
11/1/2020Good
12/3/2020Good
22/6/2020Bad
31/10/2020Bad
32/15/2020Bad
42/22/2020Good

 

What I want is to create a distinct count that shows me how many stores have "Good" as a result. In this example, it should show 2, because store #1 & #3 are the only ones. 

 

I have tried several solutions posted, including the ones found here

https://community.powerbi.com/t5/Desktop/DISTINCTCOUNT-with-filters/td-p/410253

and 

https://community.powerbi.com/t5/Desktop/Distinct-count-based-on-a-criteria-from-another-column/m-p/...

 

Good_result=
CALCULATE (
DISTINCTCOUNT ( Table[store ID] ),
FILTER(Table,Table[Result] = "Good"
))

 

But I am not sure why Power BI keeps on returning zero on me. Any help would be greatly appreciated!

5 REPLIES 5
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

We create a sample, and the result is correct.

 

Dis1.jpg

 

Your issue may be caused by Result Measure.

You can try to put the calculation conditions in the Result measure into the Filter of Good_Result.

 

If it doesn’t meet your requirement, could you please provide the detail of the Result Measure.

Could you please provide a mockup sample based on fake data or describe the fields of each tables and the relations between tables simply?

It will be helpful if you can show us the exact expected result based on the tables. Do you want to show the result in a table visual or a card visual?

 

Please upload your files to OneDrive For Business and share the link here. Please don't contain any Confidential Information or Real data in your reply.

 

Best regards,

 

Community Support Team _ zhenbw

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

@Anonymous , Try a new measure like

countc(filter(summarize(Table, Table[Store ID], "_1", count(Table[Store ID]), "_2", calculate(count(Table[Store ID]),Table[Result] ="Good")),[_1]=[_2]),[Store ID])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks, but what is countc? If it was count, this measure doesn't seem to work. 

Greg_Deckler
Community Champion
Community Champion

@Anonymous - Perhaps:

 

Measure =
  VAR __Table = ADDCOLUMNS('Table',"Result",[Result])
RETURN
  COUNTROWS(DISTINCT(SELECTCOLUMNS(FILTER(__Table,[Result]="Good"),"Store ID",[Store ID])))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks Greg, but it is returning blank for me. 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors