Forum Discussion

MikePowerBI's avatar
MikePowerBI
Helper II
4 years ago
Solved

Excluding values from distinct count based on another column

Hi there,    I am looking to create a measure that counts the unique values of column "Batch" if the "Severity" column equals BLANK, Minor, or Event while also excluding the value from the count if...
  • VahidDM's avatar
    4 years ago

    Hi MikePowerBI 

     

    Try this measure:

    Measure =
    VAR _A =
        CALCULATETABLE (
            VALUES ( 'Table'[Batch] ),
            FILTER ( 'Table', 'Table'[Severity] IN { "", "Minor", "Event" } )
        )
    VAR _B =
        CALCULATETABLE (
            VALUES ( 'Table'[Batch] ),
            FILTER ( 'Table', 'Table'[Severity] IN { "Major", "Critical" } )
        )
    VAR _C =
        EXCEPT ( _A, _B )
    RETURN
        COUNTROWS ( _C )

     

    output:

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
    Appreciate your Kudos!!
    LinkedIn: 
    www.linkedin.com/in/vahid-dm/