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

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

Reply
webportal
Impactful Individual
Impactful Individual

Check if value in column B exists in column A

Using Power Query, I need to check for each row of MyTable if the value in column B exists in column A.

If it does, then that value should be returned, then an empy field.

This is the code I'm trying to enter into an if statement somehow:

Table.Contains(MyTable,[B],[A])

Which is returing a cyclical reference error.

5 REPLIES 5
artemus
Microsoft Employee
Microsoft Employee

Assuming this is in AddColumns...

 

Just use:

if Text.Contains([A], [B]) then
    [B]
else
   null
webportal
Impactful Individual
Impactful Individual

Hi @artemus 

thanks, it always returns B (since B is a substring of A).

I need to make an exact comparison, is there a function for that?

Oh, just use:

if [A] = [B] then
    [A]
else
    null
webportal
Impactful Individual
Impactful Individual

Hi, that makes a comparison row by row which always returns false (null).
I need to check if column B exists in the entire column A.

I think I see what you are getting at.

 

In this case instead of adding a column, do a self join. Just do a merge on the same table using [A] and [B] as the join columns

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Kudoed Authors