Add new Power Query functions and update settings for improved data handling
This commit is contained in:
22
power-query/specific/fNormalizeColumnNames.m
Normal file
22
power-query/specific/fNormalizeColumnNames.m
Normal file
@@ -0,0 +1,22 @@
|
||||
( TBL_SOURCE as table,
|
||||
optional S_RENAME_TAG as nullable text,
|
||||
optional B_DO_RENAME as nullable logical) as table =>
|
||||
let
|
||||
RenamingNeeded = if B_DO_RENAME = null then true else B_DO_RENAME,
|
||||
RenameTag = if S_RENAME_TAG = null then "" else S_RENAME_TAG,
|
||||
|
||||
InitialColumnNames = Table.ColumnNames(TBL_SOURCE),
|
||||
RenameTableColumns = if RenamingNeeded then
|
||||
let
|
||||
NewColumnNames = List.Transform(InitialColumnNames, each fReplaceFunction(_, true, S_RENAME_TAG)),
|
||||
RenameColumns = Table.RenameColumns(TBL_SOURCE,
|
||||
List.Zip({InitialColumnNames, NewColumnNames}))
|
||||
in
|
||||
RenameColumns
|
||||
else
|
||||
TBL_SOURCE,
|
||||
|
||||
ColumnsToKeep = fGetNeededColumnNames(RenameTag),
|
||||
KeepNeeded = Table.SelectColumns(RenameTableColumns, ColumnsToKeep, MissingField.Ignore)
|
||||
in
|
||||
KeepNeeded
|
||||
Reference in New Issue
Block a user