Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
RalphyDaddy
Frequent Visitor

Split or delimit column based on IF statement

Hi, not sure if this is possible.

I have a table that contains 2 columns (Level and Model).

I need the information inside the Model column, however it's positioning differs on the level.

 

Below is the example:

RalphyDaddy_0-1747242669675.png

 

The information I need:

RalphyDaddy_2-1747242697430.png

 

If LEVEL = 1, I want to split it after 2nd character to get "55"

If LEVLE =2 or 3, I want to split it after 4th character to get "45" and "10".

Is this possible?

 

Thank you.!

1 ACCEPTED SOLUTION
ExcelMonke
Super User
Super User

Hello,

Yes, this is possible. I would consider using transform to accomplish this. In transform, add a custom column with the following M language:

if [Level] = 1 then Text.Middle([Model],2,2) else Text.Middle([Model],4,2)

I used it to get this:

ExcelMonke_1-1747244449684.png

 

Hope this helps! 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

3 REPLIES 3
v-hashadapu
Community Support
Community Support

Hi @RalphyDaddy ,
I wanted to follow up and see if you’ve had a chance to review the information provided here.
If any of the responses helped solve your issue, please consider marking it "Accept as Solution" and giving it a 'Kudos' to help others easily find it.
Let me know if you have any further questions!

ryan_mayu
Super User
Super User

@RalphyDaddy 

besides the solution in pq, you can also use DAX to create a calculated column

 

Column = IF('Table'[Level]=1,mid('Table'[Model],3,2),mid('Table'[Model],5,2))
 
11.png




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ExcelMonke
Super User
Super User

Hello,

Yes, this is possible. I would consider using transform to accomplish this. In transform, add a custom column with the following M language:

if [Level] = 1 then Text.Middle([Model],2,2) else Text.Middle([Model],4,2)

I used it to get this:

ExcelMonke_1-1747244449684.png

 

Hope this helps! 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.