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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
DM_EU
Helper I
Helper I

DISTINCTCOUNT only on a certain condition

Hello,

 

I need to distinctcount the IDs when the status is only equal to "Pushed" or "Already pushed" (if an ID has a different status, don't count it). Here is a sample table :

IDStatus
1Pushed
2Pushed
2To do

 

The result should be 1 because only one ID has the status exactly equal to "Pushed" or "Already pushed". But my current measure is wrong because it returns 2. My current measure is :

 

CALCULATE(DISTINCTCOUNT 'Fact Assets'[ID]), 'Fact Assets'[Status] IN { "Pushed", "Already pushed" })
 
 

How can I get this measure to return 1 ?

 

Thank you

Best regards

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Here is one measure expression that should work.

 

Only Pushed =
COUNTROWS(
    FILTER(
        VALUES( T3[ID] ),
        ISBLANK(
            CALCULATECOUNT( T3[ID] ), NOT T3[Status] IN { "Pushed", "Already Pushed" } )
        )
    )
)

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

Please try the below measure, and check the attached file.

 

Picture2.png

 

expected result: =
VAR allid =
    VALUES ( 'Fact Assets'[ID] )
VAR idnotwant =
    CALCULATETABLE (
        VALUES ( 'Fact Assets'[ID] ),
        NOT ( 'Fact Assets'[Status] IN { "Pushed", "Already pushed" } )
    )
VAR onlyidwant =
    EXCEPT ( allid, idnotwant )
RETURN
    COUNTROWS ( onlyidwant )

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.
mahoneypat
Microsoft Employee
Microsoft Employee

Here is one measure expression that should work.

 

Only Pushed =
COUNTROWS(
    FILTER(
        VALUES( T3[ID] ),
        ISBLANK(
            CALCULATECOUNT( T3[ID] ), NOT T3[Status] IN { "Pushed", "Already Pushed" } )
        )
    )
)

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.