Forum Discussion

vc25's avatar
vc25
Helper I
6 months ago
Solved

Dynamically merge specific columns without null and output as text

Hello, in power query, I want to merge specific columns that start with "cdp" Some columns are null values which I do not want to show up in my final output. For example, I have 4 columns "cdp1" "cdp...
  • techies's avatar
    techies
    6 months ago

    Hi vc25 pls remove the highlighted lines

     

     

    Since Changed Type 3 already converts fish columns to text, you can just add the merge step after that and it will show values instead of table.

     

    AddMergedLabels =
            Table.AddColumn(
                #"Changed Type3",
                "merge",
                each
                    Text.Combine(
                        List.RemoveNulls(
                            List.Transform(
                                List.Select(
                                    Table.ColumnNames(#"Changed Type3"),
                                    each Text.StartsWith(_, "fish")
                                ),
                                (c) => Record.Field(_, c)
                            )
                        ),
                        ";"
                    ),
                type text
            )
    in
        AddMergedLabels