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
CHARLEA1
Frequent Visitor

Comparing two columns for same values using powerquery

Hi there, 

first time posting but I have been looking around a lot.

I'm trying to create a custom column which identifies for which values in column B exists in column A (i.e. they do not need to exist on the same row).
For example: 
column A   column B   custom column
orange       banana       FALSE
apple         orange        TRUE
mango       pear            FALSE

 

I have seen solutions in DAX although I need this in powerquery, because I intend to pivot the table depending on the results.

From this article: https://towardsdatascience.com/power-bi-functions-list-contains-list-containsany-list-containsall-87... I tried to use the following formula: 
= Table.AddColumn(#"Previous Step", "Custom", each List.Contains({#"Previous Step"[column A]},[column B]))

But it has not worked (everything outputs as false).

Thanks in advance!

1 ACCEPTED SOLUTION
CHARLEA1
Frequent Visitor

Thanks,

solution ended up being: = Table.AddColumn(#"Previous Step", "Custom", each List.Contains(#"Previous Step"[column A], [column B]))

View solution in original post

3 REPLIES 3
CHARLEA1
Frequent Visitor

Thanks,

solution ended up being: = Table.AddColumn(#"Previous Step", "Custom", each List.Contains(#"Previous Step"[column A], [column B]))

Anonymous
Not applicable

Darn I didn't realize that I left your opening brace in there!

 

--Nate

Anonymous
Not applicable

It'll work if you rewrite it like:

 

= Table.AddColumn(#"Previous Step", "Custom", each List.Contains({#"Previous Step[column A], [column B]))

 

--Nate

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.