Forum Discussion

Fryyy's avatar
Fryyy
Advocate II
8 years ago
Solved

multiple columns if value=1 write column name in separate column

Hello, i have a problem: ich have multiple columns like that:   Station1       Station2      Station3     Station4 0                   1                 0                0 0                   1...
  • MarcelBeug's avatar
    MarcelBeug
    8 years ago

    Assuming you have also other columns, this would be a Power Query solution:

     

    let
        Source = Table1,
        #"Added Custom" = 
            Table.AddColumn(
                Source, 
                "Stations",
                 (ThisRow) => 
                    Text.Combine(
                        List.Transform(
                            List.Select(
                                List.Zip(
                                    {Record.FieldNames(ThisRow),
                                     Record.FieldValues(ThisRow)}),
                                each _{1} = 1 and Text.StartsWith(_{0},"Station")),
                            each _{0}),
                        ", ")
                )
    in
        #"Added Custom"