Forum Discussion

hulk_deka's avatar
hulk_deka
Frequent Visitor
4 years ago
Solved

CHOOSING ROWS WITH PARTICULAR VALUE.

i have two columns with the following values col A  col B a         1 b         2 c         2 d         1 e         2   I would like to have a count from column B with rows that have only '2'...
  • v-yanjiang-msft's avatar
    3 years ago

    Hi hulk_deka ,

    According to your description, here's my solution. 

    Create a measure.

    M =
    COUNTROWS ( FILTER ( 'Query1', 'Query1'[col B] = 2 ) )
    

    Get the result. 

    As you say "column B with rows that have only '2' as an entry", I'm not sure if you mean for example the below sample, the 2 of e should not be included, as it still as a value 1. 

    If this is the case, modify the formula to:

    Measure =
    CALCULATE (
        DISTINCTCOUNT ( Query1[col A] ),
        FILTER (
            'Query1',
            COUNTROWS (
                FILTER (
                    'Query1',
                    'Query1'[col A] = EARLIER ( 'Query1'[col A] )
                        && 'Query1'[col B] <> 2
                )
            ) = 0
        )
    )
    

    Get the correct result according to the modified sample.

    I attach my sample below for your reference.

     

    Best Regards,
    Community Support Team _ kalyj

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