Skip to content

Instantly share code, notes, and snippets.

@Hugoberry
Last active February 23, 2017 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hugoberry/f413d1dd8a13ec9cf15937029035f0bf to your computer and use it in GitHub Desktop.
Save Hugoberry/f413d1dd8a13ec9cf15937029035f0bf to your computer and use it in GitHub Desktop.
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