Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Nightlight
New Member

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 2
v-juanli-msft
Community Support
Community Support

Hi @Nightlight

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

8.png

 

Best regards

Maggie

Zubair_Muhammad
Community Champion
Community Champion

@Nightlight

 

Hi

 

You can use this calculated column in Power BI

 

Column =
CONTAINS (
    FILTER ( Table1, Table1[City] = EARLIER ( Table1[City] ) ),
    [Transportation], "Metro"
)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.