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

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

Reply

DISTINCTCOUNT based on two rows from another column

Hi,

 

I'm trying to do a DISTINCTCOUNT on the ID column below, but it should count only if there are DRAFT and FINAL status values for the same ID, if there is only one status (be it draft or final) the id should not be counted.

 

filipeoliveira_0-1635781649821.png

 

So it should count MER2021073, LOG2021051 and CGM2021032 only.

 

Someone could help?

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@filipeoliveira , use this measure with id

Countx(filter(summarize(Table, Table[ID], "_1", calculate(Distinctcount(Table[Status]), filter(Table, Table[Status] in {"DRAFT","FINAL"}) )),[_1]=2),[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

View solution in original post

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hi, @filipeoliveira 

According to your description, I can clearly understand your requirement, you want to count the amount of the ID if the status is less than 2, right? I think you can create a single measure to use a virtual table like this to achieve your requirement:

Count =

var _table=SUMMARIZE(DISTINCT('Table'),[ID],"Count",DISTINCTCOUNT('Table'[STATUS]))

return

COUNTX(FILTER(_table,[Count]<2),[ID])

 

And you can create a card chart to get what you want, like this:

vrobertqmsft_0-1635847760122.png

 

You can download my test pbix file below

 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

Jihwan_Kim
Super User
Super User

Hi,

please check the below picture and the attached pbix file.

 

Picture1.png

 

Distinct Count Draft and Final: =
VAR currentid =
MAX ( Data[ID] )
VAR currentidtable_draft =
FILTER ( ALL ( Data ), Data[ID] = currentid && Data[STATUS] = "DRAFT" )
VAR currentidtable_final =
FILTER ( ALL ( Data ), Data[ID] = currentid && Data[STATUS] = "FINAL" )
VAR conditions =
IF (
COUNTROWS ( currentidtable_draft ) >= 1
&& COUNTROWS ( currentidtable_final ) >= 1,
1
)
RETURN
conditions
 
Total fix: =
SUMX( VALUES( Data[ID] ), [Distinct Count Draft and Final:] )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
amitchandak
Super User
Super User

@filipeoliveira , use this measure with id

Countx(filter(summarize(Table, Table[ID], "_1", calculate(Distinctcount(Table[Status]), filter(Table, Table[Status] in {"DRAFT","FINAL"}) )),[_1]=2),[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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.