Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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