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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
gouldc2
New Member

pull one character out of text string

I have a list of serial codes that I want to pull individual characters out of that relate to a date made. For instance I want the third digit (7) out of CH78KG092 to put into a new column because that corresponds to the year made (2017). In excel I use a mid function. How to do in power BI? Thanks.

1 ACCEPTED SOLUTION
drewlewis15
Solution Specialist
Solution Specialist

There are a couple different functions that you can use, one being Text.Middle.

 

Below is how that function works, but you can always use the following link to play around with other functions:

 

https://msdn.microsoft.com/en-us/query-bi/m/power-query-m-function-reference

 

Text.Middle(text as nullable text, start as number, optional count as nullable number) as nullable text

About

Returns count characters, or through the end of text; at the offset start.

Example 1

Find the substring from the text "Hello World" starting at index 6 spanning 5 characters.

Text.Middle("Hello World", 6, 5)  
Equals: "World"

 

View solution in original post

2 REPLIES 2
ChrisMendoza
Resident Rockstar
Resident Rockstar

DAX has MID( ) as well

 

1.PNG

 

M Code also has similar Text.Middle( )

 

2.PNG






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



drewlewis15
Solution Specialist
Solution Specialist

There are a couple different functions that you can use, one being Text.Middle.

 

Below is how that function works, but you can always use the following link to play around with other functions:

 

https://msdn.microsoft.com/en-us/query-bi/m/power-query-m-function-reference

 

Text.Middle(text as nullable text, start as number, optional count as nullable number) as nullable text

About

Returns count characters, or through the end of text; at the offset start.

Example 1

Find the substring from the text "Hello World" starting at index 6 spanning 5 characters.

Text.Middle("Hello World", 6, 5)  
Equals: "World"

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors