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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
vimina
Frequent Visitor

Extract last 4 characters ignoring leading from a field

I have a column in a table which is the combination of numeric and special charecters. I would like to extract last four charecters before the delimeter and ignore the leading 0 from it and populate the values to a new column. (Looking for a method to achieve this using M )

Sample Data:

vimina_0-1678967181361.png

As highligted with a color, there are cases when an extra special charecter appear in the data(can be because of human error), that should be corrected in the result.
SQL query used: LTRIM(RIGHT(SPLIT_PART(Column1, '-', 0), 4), 0) AS Desired Result (This query doesnt address 152-00003- values)

Any Help will be appreciated.
Thank You.

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

Is this what you are looking for?
Screen Capture #616.png

Number.FromText(
    Text.End(
    Text.BeforeDelimiter([Column1],"-",RelativePosition.FromStart),
    4)
    )

View solution in original post

4 REPLIES 4
Ahmedx
Super User
Super User

it might be better that way!
Screen Capture #619.png

vimina
Frequent Visitor

Yes but for the values like (152-00003-) it should produce 3 as the result instead if 152

Screen Capture #618.png

 

if  List.Count(Text.Split([Column1],"-"))>2 then Number.FromText(Text.End(Text.BeforeDelimiter([Column1],"-",
    RelativePosition.FromEnd),4))
    else Number.FromText(Text.End(Text.BeforeDelimiter([Column1],"-",
    RelativePosition.FromStart),4))

 

Ahmedx
Super User
Super User

Is this what you are looking for?
Screen Capture #616.png

Number.FromText(
    Text.End(
    Text.BeforeDelimiter([Column1],"-",RelativePosition.FromStart),
    4)
    )

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.