Forum Discussion

jackieremidez's avatar
jackieremidez
New Member
3 years ago
Solved

Fill in text strings from one column by using data from another, and then doing it vice-versa

Hello,   I have some data that looks like this:   Prod Code A        Prod Code B       Prod Code Description 1234Q                      ABCD                            Blah                     ...
  • jbwtp's avatar
    3 years ago

    Hi all,

     

    this is another option to resolve it:

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNglU0lFydHJ2AVJOOYkZSrE60UpYhGBKsYmhqzU1M7cA8l3d3D1AOpCEgCgyMSURZglUBVwIVSNEOBYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Prod Code A" = _t, #"Prod Code B" = _t, #"Prod Code Description" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Prod Code A", type text}, {"Prod Code B", type text}, {"Prod Code Description", type text}}),
        #"Replaced Value" = Table.ReplaceValue(#"Changed Type", each {[Prod Code A], [Prod Code B]}, null, (x, y, z)=> if y{0} = "" then y{1} else (if y{1} = "" then y{0} else x),{"Prod Code A", "Prod Code B"})
    in
        #"Replaced Value"

     

     

    jackieremidez , you need to replace the reference to #"Changed Type"  in  Table.ReplaceValue(#"Changed Type"  to the name of your last step before this needs to be actioned.

     

    Cheers,

    John