Forum Discussion
Based on duplicated value, replace valus in another column
- Anonymous6 years ago
given that the AIB answer is correct, if you are better off with the PBI GUI, these are the steps you can follow to get the result:
order before column2 acsending, then column1 descending
finally, fill down column1
Hi ShiMaria
Place this code in a blank query to see the steps. The #"Added Custom" step is the important one:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTJVitWJVlKGs4yALBMwyxjIMlOKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [BATCH = _t, PO = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"BATCH", type text}, {"PO", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [BATCH] = "#" then List.Max(Table.SelectRows(#"Changed Type", (inner)=> inner[PO]=[PO] and (inner)[BATCH]<>"#")[BATCH]) else [BATCH]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"BATCH"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Custom", "BATCH"}}),
#"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"BATCH", "PO"})
in
#"Reordered Columns"
Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
may be I incert it wrongly, but it doesn't make any difference to my tables..
- Anonymous6 years agoNot applicable
given that the AIB answer is correct, if you are better off with the PBI GUI, these are the steps you can follow to get the result:
order before column2 acsending, then column1 descending
finally, fill down column1