Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hello, I am trying to delete Rows
Problem:
Account_number | SEE_Number | SIO_Status
GA12234 | SEE-234-567 | NUll ----------> This row should be deleted without the other
GA12234 | SEE-234-567 | Cancelled
GA 55555 | SEE-001-009 | NUll
The first account number is duplicate. So I want my query to retain the account_number and its "SIO_Status" if it has any and duplicate the other record BUT at the same time retain the null values of the other Account_number.
Desired Solution:
Account_number | SEE_Number | SIO_Status
GA12234 | SEE-234-567 | Cancelled
GA 55555 | SEE-001-009 | NUll
Solved! Go to Solution.
Hi @Anonymous ,
M code for your reference.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcnc0NDIyNlHSUQp2ddUFsnRNzcyBPL9QHx+lWB3cCpwT85JTc3JSU6CqTEEAqsrAwBCILeHGxAIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Account = _t, SEE_Number = _t, SIO_Status = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Account", type text}, {"SEE_Number", type text}, {"SIO_Status", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Length([SIO_Status])), #"Grouped Rows" = Table.Group(#"Added Custom", {"SEE_Number", "Account"}, {{"Count", each List.Max([Custom]), type number}}), #"Added Custom1" = Table.AddColumn(#"Grouped Rows", "Custom", each if[Count] = 9 then "Cancelled" else null), #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Count"}) in #"Removed Columns"
Hi @Anonymous ,
M code for your reference.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcnc0NDIyNlHSUQp2ddUFsnRNzcyBPL9QHx+lWB3cCpwT85JTc3JSU6CqTEEAqsrAwBCILeHGxAIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Account = _t, SEE_Number = _t, SIO_Status = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Account", type text}, {"SEE_Number", type text}, {"SIO_Status", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Length([SIO_Status])), #"Grouped Rows" = Table.Group(#"Added Custom", {"SEE_Number", "Account"}, {{"Count", each List.Max([Custom]), type number}}), #"Added Custom1" = Table.AddColumn(#"Grouped Rows", "Custom", each if[Count] = 9 then "Cancelled" else null), #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Count"}) in #"Removed Columns"
Thank you!!! That really helped.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
126 | |
78 | |
78 | |
59 | |
51 |
User | Count |
---|---|
165 | |
83 | |
68 | |
68 | |
59 |