Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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 A | Column B | Column C | New Column |
1234 | test | 2323 | null |
4321 | kdjkdf | 1234 | 1234 |
8939 | dkikdi | 1234 | 1234 |
383738 | ueuj | 8939 | 8939 |
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.
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.
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.
=let a=List.Buffer(TableName[ColumnA]) in Table.AddColumn(TableName,"NewColumn",each if List.Contains(a,[ColumnC] then [ColumnC] else null)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
9 | |
6 | |
6 | |
6 | |
6 |