Forum Discussion

NOVICE02's avatar
NOVICE02
Helper III
6 years ago
Solved

filter with multiple conditions

Hi all,

 

Stuck here.. Data looks like this:

BanPTPhandledD
1230y0
4561y1
7890y0
7880y1

 

What i need to do is this: I want to count the bans with condition = Y and add  the following 2 conditions...

D = 0 and ptp = 0

D = 0 and ptp =1 

D = 1 and ptp = 1

 

Wht is the best way to create this measure ? I can't figure out the dax formula. Any guidance is appreciated. Thank you!

  • Hey,

     

    I would create this measure:

    Measure = 
    var filtertable = 
        UNION(
            ROW("handled" , "Y" , "D" , 0 , "ptp" , 0)
            , ROW("handled" , "Y" , "D" , 0 , "ptp" , 1)
            , ROW("handled" , "Y" , "D" , 1 , "ptp" , 1)
        )
    return
    CALCULATE(
        COUNTROWS('Table')
        , TREATAS(filtertable , 'Table'[handled] , 'Table'[D] , 'Table'[PTP])
    )

    Based on the sample data you provided, the measure returns 3 and can be used e.g. on a card visual like so:

    Hopefully this is what you are looking for.

     

    Regards,

    Tom

     

3 Replies

  • Hey,

     

    I would create this measure:

    Measure = 
    var filtertable = 
        UNION(
            ROW("handled" , "Y" , "D" , 0 , "ptp" , 0)
            , ROW("handled" , "Y" , "D" , 0 , "ptp" , 1)
            , ROW("handled" , "Y" , "D" , 1 , "ptp" , 1)
        )
    return
    CALCULATE(
        COUNTROWS('Table')
        , TREATAS(filtertable , 'Table'[handled] , 'Table'[D] , 'Table'[PTP])
    )

    Based on the sample data you provided, the measure returns 3 and can be used e.g. on a card visual like so:

    Hopefully this is what you are looking for.

     

    Regards,

    Tom