To just remove the last character you can use Text.RemoveRange
:
let
Source = Excel.CurrentWorkbook(){[Name="Table14"]}[Content],
#"Added Custom" = Table.AddColumn(Source, "Custom", each Text.RemoveRange([Query],Text.Length([Query])-1))
in
#"Added Custom"
To convert strings ending in K
or M
to their real numbers, you can do things a bit more complex: (Note that I assumed K=1000
and M=1000000
to be consistent; other systems have M=1000
and MM=1000000
. I am not aware of a system where K=100000
but you can easily edit the code if you need to)
let
Source = Excel.CurrentWorkbook(){[Name="Table14"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Query", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each
let
x = Text.End([Query],1),
y = Number.From(Text.RemoveRange([Query],Text.Length([Query])-1)),
result = if x = "K" then y * 1000
else if x = "M" then y * 1000000
/*Note that code assumes that if string doesn't end with K or M
it is a number. You may want to test specifically for that to avoid errors*/
else Number.From([Query])
in
result, type number)
in
#"Added Custom"
If you are having trouble entering the code, you can add it as a custom column to your existing code. Be sure to change the column identifier in the code to whatever the column name is in your code that references the table you show. Possibly [Query.Avg Volume]
eg:
excel
tag there). sorry, I don't have access to Power Query. I'm not sure if this will help : support.microsoft.com/en-us/office/… – p._phidot_