Forum Discussion

Nightlight's avatar
Nightlight
New Member
8 years ago

IF+COUNTIF in POWERBI

Actually, I have met a problem about how to filter the special column by criterias.In Exccel,if+Countifs is easy.

City             Transportation       Metro?
Beijing        Air                           Yes
Beijing        Metro                      Yes
Beijing        Train                        Yes
Shanghai    Air                           Yes
Shanghai    Metro                      Yes
Shanghai    Train                        Yes
Nanchang   Air                           No
Nanchang   Train                       No

so my question is : how to get column"Metro?" by DAX functions?

2 Replies

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Icon for Community Champion rankCommunity Champion

    Nightlight

     

    Hi

     

    You can use this calculated column in Power BI

     

    Column =
    CONTAINS (
        FILTER ( Table1, Table1[City] = EARLIER ( Table1[City] ) ),
        [Transportation], "Metro"
    )
  • v-juanli-msft's avatar
    v-juanli-msft
    Icon for Community Support rankCommunity Support

    Hi Nightlight

    As tested, Zubair_Muhammad's formula can get the expected results as the picture you provided.

     

    Best regards

    Maggie