I’m trying to extract a part of a string field [Short description] and place it in a new custom field in Power BI Query [NewDesc].
For example, if the [Shoer description] field is:
“SNOW – 1234 – My description here”
I would like the [NewDesc] field to return everything after the 4th space, ie:
“My description here”
My query in the editor is:
= Table.AddColumn(#"Reordered Columns1", "NewDesc", each
if Text.StartsWith([Short description], "Sentinel") then
let
// Split the text by spaces
SplitText = Text.Split([Short description], " "),
// Find the index of the 4th space
FourthSpaceIndex = List.PositionOf(SplitText, "", 4) - 1,
// Extract the text after the 4th space
ExtractedText = Text.Middle([Short description], FourthSpaceIndex + 2)
in
ExtractedText
else
[Short description]
)
I’ve tried number of ways, but for this, the error is:
Expression.Error: We cannot apply operator - to types List and Number.
Details:
Operator=-
Left=[List]
Right=1
Can anyone help correct my query please?
Thanks, Mark