Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreThe FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now
I am new to Power BI and need some help. I need to parse the left part of the column before the (-) but there are several fields where there is no dash. In these cases, I want it to parse the left part of the column before the (.) and if there is neither, I want it to give me the entire field. Any suggestions on how I can accomplish that?
Sample Data:
Solved! Go to Solution.
You didn't mention if you want the result in the same column or in a new column.
The query below includes both alternatives.
let
Source = #table(type table[PART_ID = text],{{"12-3983.98u"},{"897.yfdwhv"},{"jhjkkjygw"}}),
Added = Table.AddColumn(Source, "ParsedPart", each if Text.Contains([PART_ID],"-") then Text.BeforeDelimiter([PART_ID],"-") else Text.BeforeDelimiter([PART_ID],".")),
Transformed = Table.TransformColumns(Added,{{"PART_ID", each if Text.Contains(_,"-") then Text.BeforeDelimiter(_,"-") else Text.BeforeDelimiter(_,".")}})
in
Transformed
This is how step "Added" looks like in the Query Editor with the popup for adding a custom column:
You didn't mention if you want the result in the same column or in a new column.
The query below includes both alternatives.
let
Source = #table(type table[PART_ID = text],{{"12-3983.98u"},{"897.yfdwhv"},{"jhjkkjygw"}}),
Added = Table.AddColumn(Source, "ParsedPart", each if Text.Contains([PART_ID],"-") then Text.BeforeDelimiter([PART_ID],"-") else Text.BeforeDelimiter([PART_ID],".")),
Transformed = Table.TransformColumns(Added,{{"PART_ID", each if Text.Contains(_,"-") then Text.BeforeDelimiter(_,"-") else Text.BeforeDelimiter(_,".")}})
in
Transformed
This is how step "Added" looks like in the Query Editor with the popup for adding a custom column:
This is perfect! Thank you so much. I wanted them in the same column and the second options works great.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 52 | |
| 38 | |
| 37 | |
| 19 | |
| 18 |
| User | Count |
|---|---|
| 67 | |
| 67 | |
| 34 | |
| 32 | |
| 29 |