The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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:
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.
Solved! Go to Solution.
Is this what you are looking for?
Number.FromText(
Text.End(
Text.BeforeDelimiter([Column1],"-",RelativePosition.FromStart),
4)
)
it might be better that way!
Yes but for the values like (152-00003-) it should produce 3 as the result instead if 152
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))
Is this what you are looking for?
Number.FromText(
Text.End(
Text.BeforeDelimiter([Column1],"-",RelativePosition.FromStart),
4)
)