Forum Discussion

Belle2024's avatar
Belle2024
Helper I
2 years ago
Solved

Combining results from different columns

  Hi I am looking for some help, I am trying to create a new column that will combine the data in columns Data 1 and Data 2 and if one is blank it will return the value of the other and if bot...
  • dufoq3's avatar
    dufoq3
    2 years ago

    Change address to document

     

    let
        Source = Excel.Workbook(File.Contents("C:\Downloads\sample data (1).xlsx"), true, true),
        #"Completed 2024!_xlnm _FilterDatabase_DefinedName" = Source{[Item="Completed 2024!_xlnm._FilterDatabase",Kind="DefinedName"]}[Data],
        #"Changed Type" = Table.TransformColumnTypes(#"Completed 2024!_xlnm _FilterDatabase_DefinedName",{{"sort code", Int64.Type}, {"Account number", Int64.Type}, {"If not 12345", Int64.Type}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [If not 12345] <> null then Text.From([If not 12345]) else Text.Combine({Text.From([sort code]), Text.From([Account number])}, " "), type text)
    in
        #"Added Custom"