Forum Discussion
m query remove character from column in a table
- Anonymous9 years ago
Text.Remove doesn't take a column as the input. It takes a text value. Read the documentation on it. It's not meant to operate on full columns. It's meant to operate on a single text value. I can't tell you how to use Text.Remove on a column because that's not what that function is for. It is not the correct function to use in order to reach the outcome you want. Wrong tool for the job. And by the way, ASKING THE SAME QUESTION A SECOND TIME IN ALL CAPS DOESN'T CHANGE THE ANSWER.
If you're hellbent on using that particular function for some reason, I suppose you could use it in a new column definition formula where you copy the text values from each row in another column, then use Text.Remove to remove those letters. But that leaves you with two columns, one with o's, one without. So you'll probably find that answer unacceptable too.
If you want to reference a column in M code, you have to use a formula that takes a column as an argument. Perhaps something like Table.ReplaceValue...
The interface option, as you call it, just generates M code. You can use the Replace Values button or you can type this code by hand. They are literally the same thing, except one of them takes longer to do.
Hi everyone,
For those that complained about the question instead of providing an appropiate answer, next time please just not comment.
If you say the functions are not built for certain task you better assume you just not know enought instead.
Here is the line of code you were probably looking for mate:
Custom2 = Table.TransformColumns(#"ChangedType", {{ "CategoryName", each Text.Remove(_,"o") }} )
*Note this is case sensitive. The easiest way to go around this is to repeat the same line of code changing the o by an O or whatever character you want to remove (there are other more sofisticated ways to do it, of course, but sure you'll find them in the future).
Keep the learning going linoybar!