Skip to content

Instantly share code, notes, and snippets.

Created February 11, 2018 15:36
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 anonymous/3da28b3b4b0cc2b4a2d06e47ac233dfe to your computer and use it in GitHub Desktop.
Save anonymous/3da28b3b4b0cc2b4a2d06e47ac233dfe to your computer and use it in GitHub Desktop.
// code written by Hans Peter Pfister, www.powerbi-pro.com
(text as text) =>
let
// Convert string into list, splitted by char
Table.FromList = Table.FromList(Text.ToList(text), Splitter.SplitByNothing(), null, null, ExtraValues.Error),
// Merge with table "Replacements"
Merge = Table.Buffer(Table.NestedJoin(Table.FromList,{"Column1"},Replacements,{"WrongValue"},"KorrekturLISTE",JoinKind.LeftOuter)),
Expand = Table.ExpandTableColumn(Merge, "KorrekturLISTE", {"WrongValue", "CorrectValue"}, {"WrongValue", "CorrectValue"}),
// Add column with correct values
Added_Column_with_corrections = Table.AddColumn(Expand, "Benutzerdefiniert", each if [Column1]=[WrongValue] then [CorrectValue] else [Column1]),
//Tidy up
Remove_Columns = Table.SelectColumns(Added_Column_with_corrections,{"Benutzerdefiniert"}),
Convert_to_List = Remove_Columns[Benutzerdefiniert],
Result = Text.Combine(Convert_to_List)
in
Result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment