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
ysherriff
Resolver II
Resolver II

M Code to extract between characters that are not same position

Hi all,

Does anyone know how to extract the year from this text string? I trired "Text Extraction" and "Delimiter" but it is not coming out the way I want.

I want the year in one column but I am also showing "Gen".


Thank you for your help

 

ysherriff_0-1668711469393.png

 

1 ACCEPTED SOLUTION

Thank you but this solution works


List.RemoveNulls (
List.Transform (
Text.Split ( _[Campaign Name], "-" ),
each try Number.From ( _ ) otherwise null
)
){0}

 

 

ysherriff_0-1668724064023.png

 

View solution in original post

2 REPLIES 2
Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

Hi @ysherriff - you could try something like Text.Remove - PowerQuery M | Microsoft Learn or Text.Select - PowerQuery M | Microsoft Learn

 

Select = Text.Select( [Text] , {"0".."9"} )
Remove = Text.Remove( [Text] , {"a".."z", "A".."Z"})

 

 

Thank you but this solution works


List.RemoveNulls (
List.Transform (
Text.Split ( _[Campaign Name], "-" ),
each try Number.From ( _ ) otherwise null
)
){0}

 

 

ysherriff_0-1668724064023.png

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors