This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
I'm trying to extract the text from a column using the following 2 scenarios:
If column contains "/" then extract the remaining word after "/".
If column contains "()" extract the word from the last parantheses.
If I test each condition separately, it works as expected but I'm unable to join these 2 conditions into a single statement with a if/else/then statement.
What am I missing?
#"Transform Values" = Table.TransformColumns(#"Duplicated Column", {{"ExtractedTranform", if each Text.Contains([Column1],"/") then each Text.AfterDelimiter(_, "/") else each Text.BetweenDelimiters(_, "(", ")", {0, RelativePosition.FromEnd}, 0), type text}} )Expression.Error: We cannot apply field access to the type Text.
Solved! Go to Solution.
Hi, I am able to achieve using Split Column and some M query.
As you can see, Col1 was initial column. Col2 and Custom are intermediate columns and 4th one is the final column.
Source:
Below is the M Query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8kjNyclXCMlILUpVitUB8fXRBUB8DbCAplJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column1", Splitter.SplitTextByEachDelimiter({"/"}, QuoteStyle.Csv, true), {"Column1.1", "Column1.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", type text}, {"Column1.2", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each Text.BetweenDelimiters([Column1.1],"(",")")),
#"Added Conditional Column" = Table.AddColumn(#"Added Custom", "Formatted", each if [Column1.2] <> null then [Column1.2] else if [Custom] <> "" then [Custom] else [Column1.1])
in
#"Added Conditional Column"
If this helps to resolve your problem, then please mark it as solution, thanks
Samrat
Hi, I am able to achieve using Split Column and some M query.
As you can see, Col1 was initial column. Col2 and Custom are intermediate columns and 4th one is the final column.
Source:
Below is the M Query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8kjNyclXCMlILUpVitUB8fXRBUB8DbCAplJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column1", Splitter.SplitTextByEachDelimiter({"/"}, QuoteStyle.Csv, true), {"Column1.1", "Column1.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", type text}, {"Column1.2", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each Text.BetweenDelimiters([Column1.1],"(",")")),
#"Added Conditional Column" = Table.AddColumn(#"Added Custom", "Formatted", each if [Column1.2] <> null then [Column1.2] else if [Custom] <> "" then [Custom] else [Column1.1])
in
#"Added Conditional Column"
If this helps to resolve your problem, then please mark it as solution, thanks
Samrat
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 27 | |
| 25 | |
| 23 | |
| 19 | |
| 14 |
| User | Count |
|---|---|
| 50 | |
| 46 | |
| 19 | |
| 18 | |
| 18 |