This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreDid you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now
In my data there are several duplicates of Record ID and Brand. The same combination fo Record ID and Brand can refer to different Inv IDs. I want to remove those cases Record ID / Brand combination where Inv ID is empty when for the same Record ID / Brand combination a row with an Inv ID exists. For cases where there is only a single row for a Record ID / Brand combination where Inv ID is empty, I want to keep that. Does anyone know how to do that? I'm stuck...
See the below example:
The table I have:
| Record ID | Brand | Inv ID |
| R1 | Brand1 | I1 |
| R1 | Brand1 | I2 |
| R1 | Brand1 | null |
| R2 | Brand2 | null |
| R3 | Brand3 | I3 |
| R4 | Brand4 | null |
| R4 | Brand4 | I4 |
The table I'd like to return:
| Record ID | Brand | Inv ID |
| R1 | Brand1 | I1 |
| R1 | Brand1 | I2 |
| R2 | Brand2 | null |
| R3 | Brand3 | I3 |
| R4 | Brand4 | I4 |
Solved! Go to Solution.
Group by Record ID, then process each subtable:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCjJU0lFyKkrMSwExPA2VYnUwBI2wCEKEjGBCRnAhY5gQiOFpDBE0gQmawNWhCHmaKMXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Record ID" = _t, Brand = _t, #"Inv ID" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{
{"Record ID", type text}, {"Brand", type text}, {"Inv ID", type text}}),
//Group by ID, then process each subtable
#"Grouped Rows" = Table.Group(#"Changed Type", {"Record ID"}, {
{"Rem Dups", (t)=>
let
unique = Table.Distinct(t),
#"Rem Nulls" = if Table.RowCount(unique) > 1
then Table.SelectRows(unique, each [Inv ID] <> null and [Inv ID] <> "") else unique
in #"Rem Nulls",
type table [Record ID=nullable text, Brand=nullable text, Inv ID=nullable text]}}),
#"Expanded Rem Dups" = Table.ExpandTableColumn(#"Grouped Rows", "Rem Dups", {"Brand", "Inv ID"}, {"Brand", "Inv ID"})
in
#"Expanded Rem Dups"Data
Results
Thank you so much, it works perfectly!
Group by Record ID, then process each subtable:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCjJU0lFyKkrMSwExPA2VYnUwBI2wCEKEjGBCRnAhY5gQiOFpDBE0gQmawNWhCHmaKMXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Record ID" = _t, Brand = _t, #"Inv ID" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{
{"Record ID", type text}, {"Brand", type text}, {"Inv ID", type text}}),
//Group by ID, then process each subtable
#"Grouped Rows" = Table.Group(#"Changed Type", {"Record ID"}, {
{"Rem Dups", (t)=>
let
unique = Table.Distinct(t),
#"Rem Nulls" = if Table.RowCount(unique) > 1
then Table.SelectRows(unique, each [Inv ID] <> null and [Inv ID] <> "") else unique
in #"Rem Nulls",
type table [Record ID=nullable text, Brand=nullable text, Inv ID=nullable text]}}),
#"Expanded Rem Dups" = Table.ExpandTableColumn(#"Grouped Rows", "Rem Dups", {"Brand", "Inv ID"}, {"Brand", "Inv ID"})
in
#"Expanded Rem Dups"Data
Results
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 3 |