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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
jj101
Frequent Visitor

PowerQuery - Checking if Value in one column appears in a different columan

I am trying to create a column in power query when checking to see if the value in column 'C' resides in column 'B'. Example table below

Column AColumn BColumn CNew Column
1234test2323null
4321kdjkdf12341234
8939dkikdi12341234
383738ueuj89398939

 

This data set currently has over 200,000 rows. I have tried "List.Contains(TableName Column C, Column A)"  in the query editor but does not give the correct in puts. 

3 REPLIES 3
_AAndrade
Super User
Super User

Hi @jj101,

Please try this code:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TYoxDsAgDAP/kpmFGKnhLShbqAQZC/9vytTJPp9bo8wolGj1Z0UwGKSpUQHnYLfpdkc5t09IRQ02H27jLyC4ILHsvmfEOaq+", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Column A" = _t, #"Column B" = _t, #"Column C" = _t]),
    ChangedType = Table.TransformColumnTypes(Source,{{"Column A", Int64.Type}, {"Column B", type text}, {"Column C", Int64.Type}}),
    ListColumnA = Table.Column(Source, "Column A"),
    AddCustomColumn = Table.AddColumn(Source, "New Column", each if List.Contains(ListColumnA, [Column C]) then [Column C] else null)
in
    AddCustomColumn

 

I'm attaching a pbix file as well.





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




So when I tried this I receive "PreviewError: The type of the current preview is too complex to display." I have gone in and tried to convert the column to a list and when I do that it basically removes all of the rest of the columns. 

 

I should note that this source is a database. 

wdx223_Daniel
Super User
Super User

=let a=List.Buffer(TableName[ColumnA]) in Table.AddColumn(TableName,"NewColumn",each if List.Contains(a,[ColumnC] then [ColumnC] else null)

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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