Add new Power Query functions and update settings for improved data handling
This commit is contained in:
8
power-query/specific/fDummyTable.m
Normal file
8
power-query/specific/fDummyTable.m
Normal file
@@ -0,0 +1,8 @@
|
||||
(optional LST_DUMMY_DATA as nullable list,
|
||||
optional LST_COLUMNS as nullable list) as table =>
|
||||
let
|
||||
DummyColumns = if LST_COLUMNS = null then LST_DUMMY_DATA else LST_COLUMNS,
|
||||
DummyData = if LST_DUMMY_DATA = null then List.Repeat({null}, List.Count(DummyColumns)) else LST_DUMMY_DATA,
|
||||
Dummy = #table(DummyColumns, {DummyData})
|
||||
in
|
||||
Dummy
|
||||
5
power-query/specific/fGetNeededColumnNames.m
Normal file
5
power-query/specific/fGetNeededColumnNames.m
Normal file
@@ -0,0 +1,5 @@
|
||||
(optional S_RENAME_TAG as text) as list =>
|
||||
let
|
||||
ColumnsToKeep = Table.Distinct(Table.SelectColumns(Table.SelectRows(fP("RENAMING_RULES"), each ([#"#"] = S_RENAME_TAG)),{"НОВЫЙ"}))[НОВЫЙ]
|
||||
in
|
||||
ColumnsToKeep
|
||||
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
|
||||
9
power-query/specific/fNormalizeMalfCode.m
Normal file
9
power-query/specific/fNormalizeMalfCode.m
Normal file
@@ -0,0 +1,9 @@
|
||||
let
|
||||
Source = (anyCode as nullable any) as text => let
|
||||
TrimCode = try Text.Trim(Text.From(anyCode)) otherwise "PARSE-ERROR",
|
||||
MarkNulls = if (TrimCode = null) or (TrimCode = "") or (TrimCode = "0") then "NOT-PROVIDED" else TrimCode,
|
||||
Normalize = try Text.Upper(MarkNulls) otherwise "PARSE-ERROR"
|
||||
in
|
||||
Normalize
|
||||
in
|
||||
Source
|
||||
10
power-query/specific/fNormalizeSKU.m
Normal file
10
power-query/specific/fNormalizeSKU.m
Normal file
@@ -0,0 +1,10 @@
|
||||
let
|
||||
Source = (anySKU as any) as number => let
|
||||
RemoveFullStop = Text.Replace(Text.From(anySKU), ".", ""),
|
||||
TrimSKU = Text.Trim(RemoveFullStop),
|
||||
MarkNulls = if (TrimSKU = null) or (TrimSKU = "") or (TrimSKU = "0") then -36001 else TrimSKU,
|
||||
Normalize = try Number.From(MarkNulls) otherwise -36002
|
||||
in
|
||||
Normalize
|
||||
in
|
||||
Source
|
||||
9
power-query/specific/fNormalizeSN.m
Normal file
9
power-query/specific/fNormalizeSN.m
Normal file
@@ -0,0 +1,9 @@
|
||||
let
|
||||
Source = (anySN as nullable any) as text => let
|
||||
TrimSN = try Text.Trim(Text.From(anySN)) otherwise "-36002",
|
||||
MarkNulls = if (TrimSN = null) or (TrimSN = "") or (TrimSN = "0") then "-36001" else TrimSN,
|
||||
Normalize = try Text.Upper(MarkNulls) otherwise "-36002"
|
||||
in
|
||||
Normalize
|
||||
in
|
||||
Source
|
||||
Reference in New Issue
Block a user