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
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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.