Forum Discussion
Automatically generate column caption in power query
- 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"
Not totally clear on your scenario, but you can use Table.ColumnNames() on your [data] column to dynamically generated a list of the column names and use that in place of the hard-coded list.
Pat
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"- julhelp4 years agoHelper I
Yes that was exactly what i was looking for 😉
- julhelp4 years agoHelper I
hi AlexisOlson,
Is there also a possibility, if in the output table there are still several columns with records to output them also variably? Or du i have to output them step by step?
- AlexisOlson4 years agoSuper User
You could probably do it but it would likely be more trouble than it's worth unless you have a whole bunch of columns to expand.
- julhelp4 years agoHelper I
The problem is that I would like to apply the code variably to several tables. These do not always have the same headings and therefore cannot be hard-coded.