Skip to content

Instantly share code, notes, and snippets.

@Hugoberry
Last active February 23, 2017 17:55
Get a list of expandable columns from a table input in Power Query
expandableColumns = (_) => List.Accumulate(
Table.ColumnNames(_),
{},
(s,c)=>s&(if Type.Is(Value.Type(Record.Field(_{0},c)), type record)
or Type.Is(Value.Type(Record.Field(_{0},c)), type list)
then {c}
else {}
)
),
columnHasConsistentType = (T,Cname) =>
let
columnTypes = List.Accumulate(Table.Column(T,Cname),
{},
(s,c)=>s&{Type.RecordFields(Value.Type(c))})
in List.Accumulate(columnTypes,
true,
(s,c)=>s and (columnTypes{0}=c)),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment