Forum Discussion
Cyrilbrd
Helper IV
6 years agoText.Remove
Given a series of model code such as: BONH-P-M-16 CAN-BL-A17 88-R-AC-19 Said column also contain blanks. New calculated column need to return the following: BONH-P-M CAN-BL-A 88-R-AC Present...
ImkeF
Community Champion
6 years agoHi Cyrilbrd
there is an optional parameter in the Text.TrimEnd function that allows you to pass a list of characters that shall be removed from the end of the string:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvL389AN0PXVNTRTitWJVnJ29NN18tF1NDQHc8GEhYVukK6js66hpVJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [product_name = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"product_name", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.TrimEnd([product_name], {"0".."9"} & {"-"}))
in
#"Added Custom"
Cyrilbrd
Helper IV
6 years agoThank you for your reply, did not try yet, would not have found this by myself either.
Will this modify the Column Product_name or will it create as required a new Column Model_Code( ?
What is that part doing exactly?
Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvL389AN0PXVNTRTitWJVnJ29NN18tF1NDQHc8GEhYVukK6js66hpVJsLAA=", BinaryEncoding.Base64), Compression.Deflate))
- ImkeF6 years ago
Community Champion
Hi Cyrilbrd ,
this just creates sample data. (It is the resulting code when you enter data manually in Power BI).
Replace it with the reference to your table.
- Cyrilbrd6 years ago
Helper IV
Would that be correct?
let Source = Table.FromRows(framework_tblsalesitem), let _t = ((type text) meta [Serialized.Text = true]) in type table [product_name = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"product_name", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "model_code(", each Text.TrimEnd([product_name], {"0".."9"} & {"-"})) in #"Added Custom"How should I generate this column? Should I still use add column?