Forum Discussion
ValeriaBreve
Post Partisan
3 years agoReplace a number in a string with another one
Hello, I have a column that contains a number (a year), which is NOT FIXED - it could be any year. I need to replace it with the values of another column: In this case, what in the col...
AlienSx
Super User
3 years agoHello, ValeriaBreve M functions handbook.
[s = Text.Select( y, numbers), u = Text.Replace(y, s, x[CalculatedYear])][u]
// is just a replacement to
let
s = Text.Select( y, numbers),
u = Text.Replace(y, s, x[CalculatedYear])
in
u
You may think of a query as a record with step_names = record field names. You may use "let ... in" instead - nothing wrong with that.
Text.Select (y, numbers) selects only chars "0".."9" from your string. Result is a concatenation of all "numerical" chars in your string. Next step replaces this substring with a text value from your CalculatedYear column.
p.s. I've just noticed that CalculatedYear is Int64.Type. So please wrap x[CalculatedYear] in Text.From.
ValeriaBreve
Post Partisan
3 years agoAlienSx thank you so much for taking the time to explain!!!!!! It is much clearer now. 🙂