Forum Discussion

julhelp's avatar
julhelp
Helper I
4 years ago
Solved

Automatically generate column caption in power query

Hi,   i have a question aubout power query. Is there any posibillity to generate automatically the column caption from an table which is retrieved via api from a database?    So far i have to har...
  • AlexisOlson's avatar
    AlexisOlson
    4 years ago

    Since it's a record column, I think you'd use Record.FieldNames instead.

     

    Maybe like this:

    [...]
        #"Custom items" = Table.ExpandListColumn(#"Removed Columns", "data"),
        ColumnList = Record.FieldNames(#"Custom items"{0}[data]),
        #"Expanded data" = Table.ExpandRecordColumn(#"Custom items", "data",
            ColumnList, List.Transform(ColumnList, each "data." & _))
    in
        #"Expanded data"