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
Johannesvd
Helper I
Helper I

Count 1 column with filter

Hi all,

 

So ive got the folowing challenge as a newbie:

AssetDamage
Car1YES
Car1YES
Car2NO
Car2NO
Car2Yes
Etc.Etc.

 

this is a simplified version of the data im working on. I only  want to count the (distinct) items that only have the value "Yes" in the column "damage". So in case of the example the outcome is "1" (car 1 has only YES as damage) . Im struggeling how to apply a measure with this outcome.

 

 

 

1 ACCEPTED SOLUTION

Hi @Johannesvd

 

This measure would do the job hopefully

DistinctCars =
COUNTROWS (
    FILTER (
        SUMMARIZE (
            Cars,
            Cars[Asset],
            "Count", COUNT ( Cars[Damage] )
                - CALCULATE ( COUNT ( Cars[Damage] ), Cars[Damage] = "Yes" )
        ),
        [Count] = 0
    )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

Measure  = CALCULATE(DISTINCTCOUNT(Cars[Asset]),Cars[Damage]="YES")

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler,

 

Thank you but this also counts the YES value with car2. I only want to distinct count if there arent any "no" values with a car. 

 

Is there a solution for that?

Sorry, missed that.

 

Add this column:

 

Column = IF(MINX(FILTER(Cars,Cars[Asset]=EARLIER(Cars[Asset])),Cars[Damage])=MAXX(FILTER(Cars,Cars[Asset]=EARLIER(Cars[Asset])),Cars[Damage]),1,0)

And then change your measure to:

 

Measure = CALCULATE(DISTINCTCOUNT(Cars[Asset]),FILTER(Cars,Cars[Damage]="YES"&&Cars[Column]=1))

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Zubair_Muhammad's measure seems to work as well!


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank you both for the invested time! @Greg_Deckler @Zubair_Muhammad

 

They both work, i preffered the solution without the calculated column. 

 

where would the users be without your help!

Hi @Johannesvd

 

This measure would do the job hopefully

DistinctCars =
COUNTROWS (
    FILTER (
        SUMMARIZE (
            Cars,
            Cars[Asset],
            "Count", COUNT ( Cars[Damage] )
                - CALCULATE ( COUNT ( Cars[Damage] ), Cars[Damage] = "Yes" )
        ),
        [Count] = 0
    )
)

Regards
Zubair

Please try my custom visuals

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.