Forum Discussion
IF conditional m language
- 5 years ago
Check the following code on a blank query:let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvVxLSxPLSqpLM3KSE9LKU6sSC5LysrLzswH85VidTDUgMUcHR0J6nNKAipBNiHYyNDIEJeGWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Item Text" = _t]), #"Added Custom" = Table.AddColumn(Source, "Custom", each if Text.StartsWith([Item Text], "ELE") then Text.Middle([Item Text], 25, Text.Length([Item Text])) else "") in #"Added Custom"________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply š
- 5 years ago
Hi alexpork
Starting from the table where you have the Item text column, create a custom column by:
1. Selecting Addcolumn --> Custom column in the menu of the Query editor (https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-add-custom-column)
2. Enter this code for the column when prompted:
= if Text.StartsWith([Item Text], "ELE") then Text.Middle([Item Text], 24, Text.Length([Item Text])-24 )) else [Item Text]
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Check the following code on a blank query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvVxLSxPLSqpLM3KSE9LKU6sSC5LysrLzswH85VidTDUgMUcHR0J6nNKAipBNiHYyNDIEJeGWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Item Text" = _t]),
#"Added Custom" = Table.AddColumn(Source, "Custom", each if Text.StartsWith([Item Text], "ELE") then
Text.Middle([Item Text], 25, Text.Length([Item Text])) else "")
in
#"Added Custom"________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply š