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

Join 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.

Reply
jimboj
Regular Visitor

Update Group if a cell is different from others

Fairly new to power query but use this forum to learn, so thanks to all who post and hopefully can help me with this problem.

What I would to accomplish is within a group of numbers in ubfmemno column, if ubfmstat equals A, then change the cells in those records in column ubfmstat that equal the ubfmemno to A. As in the example below, ubfmemno has 375 in three records, with the ubfmstat showing "I" twice and "A" once. Since one ubfmemno has an "A" in that group, I need to change the other two records in the umbfstat column to "A".

jimboj_0-1656017190525.png


jimboj_0-1656017572167.png

 

Thank you for help.


 

 

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlbSUfIEYjMjc6VYHQjfEYhNDQ3hfJC8hQlU3sAAKmJqgC5iYmAEETE3hakxt0QTMTdHEzAzQxYBWW1uZoyuyRhdxMjcQCk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ubfmemno = _t, ubfmstat = _t, ubfacct = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ubfmemno", Int64.Type}, {"ubfmstat", type text}, {"ubfacct", Int64.Type}}),
    ActiveRows = Table.SelectRows(#"Changed Type", each ([ubfmstat] = "A")),
    BuffList = ActiveRows[ubfmemno],
    Custom1 = Table.ReplaceValue(#"Changed Type",each [ubfmstat],each if List.Contains(BuffList,[ubfmemno]) then "A" else [ubfmstat],Replacer.ReplaceValue,{"ubfmstat"})
in
    Custom1

 

View solution in original post

3 REPLIES 3
mussaenda
Super User
Super User

Hi @jimboj 

 

Please check the attached pbix if that is what you need.

I attached a screenshot of the output.

mussaenda_0-1656052677074.png

 

hope this helps.

 

 

Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlbSUfIEYjMjc6VYHQjfEYhNDQ3hfJC8hQlU3sAAKmJqgC5iYmAEETE3hakxt0QTMTdHEzAzQxYBWW1uZoyuyRhdxMjcQCk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ubfmemno = _t, ubfmstat = _t, ubfacct = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ubfmemno", Int64.Type}, {"ubfmstat", type text}, {"ubfacct", Int64.Type}}),
    ActiveRows = Table.SelectRows(#"Changed Type", each ([ubfmstat] = "A")),
    BuffList = ActiveRows[ubfmemno],
    Custom1 = Table.ReplaceValue(#"Changed Type",each [ubfmstat],each if List.Contains(BuffList,[ubfmemno]) then "A" else [ubfmstat],Replacer.ReplaceValue,{"ubfmstat"})
in
    Custom1

 

Vijay and mussaenda,

 

Thank you for your assistance. 

mussaenda, that is exactly what is needed, but if you left the code in the attachment, I couldn't download.

 

Vijay, That worked perfectly. Thank you so much!!! 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.