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


Go to My LinkedIn Page


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