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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Alex03260
Regular Visitor

Extract Text Based on Length of String

I have text in a column "Outline_Number" I want to extract some of the text based on the length of the string to a new column "Outline_Parent"

 

i.e. I want the whole string minus the last 2 characters, this would be easy in excel but i'm relatively new to BI.

 

"Outline_Number" = 1.1.2.2.4

 

Result

 

"Outline_Parent" = 1.1.2.2

 

Thanks 

 

Alex

 

3 REPLIES 3
AlienSx
Super User
Super User

Text.Combine(List.RemoveLastN(Text.ToList(txt), 2))

Vijay_A_Verma
Super User
Super User

You may use this

Text.Start([Outline_Number],Text.Length([Outline_Number])-2)

If you have string less than 2 in length

then

try Text.Start([Outline_Number],Text.Length([Outline_Number])-2) otherwise null

The first version worked but as expected gives an error on short string, the 2nd version gives a syntax error on the "otherwise null"

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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