Forum Discussion
jonclay
Helper IV
2 years agoTrying to change multiple values in one step
Hi everyone I'm using the following code in an attempt to change multiple values all in one step: = Table.ReplaceValue( #"Renamed Columns", each [Type], each if [Type] = "157420000" then "A" ...
- 2 years ago
jonclay here is what you can do, create a new blank query -> click advanced editor and paste the following M code, call this new query fnGetType (you can use whatever name you want)
(value) => let valueToList = Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)(value), valueToType = Text.Combine(List.Transform(valueToList, each if _ = "157420000" then "A" else if _ = "157420002" then "B" else "C"), "," ) in valueToTypenow add a new column in your table with the following expression
fnGetType([Type])
parry2k
Super User
2 years agojonclay here is what you can do, create a new blank query -> click advanced editor and paste the following M code, call this new query fnGetType (you can use whatever name you want)
(value) =>
let
valueToList = Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)(value),
valueToType = Text.Combine(List.Transform(valueToList, each if _ = "157420000" then "A" else if _ = "157420002" then "B" else "C"), "," )
in
valueToType
now add a new column in your table with the following expression
fnGetType([Type])