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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

How to convert in M language a DATE(MID(find(mod))) function

Hi there,

 

I need you help in converting the folowing Excel function in Power query:

=DATE(MID(B2;7;2);FIND(MID(B2;9;1);"ABCDEHLMPRST");MOD(MID(B2;10;2);40))

 

This function extracts the date of birth from an alphanumerical code, but i am not sure on how i can implement it on Power Query.

 

Thanks!

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Put below formula in a custom column. After pressing OK, select this custom column, Transform menu - Detect data type to convert 2 digits year to 4 digits year

= Text.Replace(Date.ToText(#date(Number.From(Text.Middle([Data],6,2)),Text.PositionOf("ABCDEHLMPRST",Text.At([Data],8))+1,Number.Mod(Number.From(Text.Middle([Data],9,2)),40))),"00","")

View solution in original post

4 REPLIES 4
Vijay_A_Verma
Super User
Super User

Put below formula in a custom column. After pressing OK, select this custom column, Transform menu - Detect data type to convert 2 digits year to 4 digits year

= Text.Replace(Date.ToText(#date(Number.From(Text.Middle([Data],6,2)),Text.PositionOf("ABCDEHLMPRST",Text.At([Data],8))+1,Number.Mod(Number.From(Text.Middle([Data],9,2)),40))),"00","")
Anonymous
Not applicable

It works like a charm, THANKS A LOT!

Anonymous
Not applicable

Sure:

An example of the string: ABCDEF74L71781E, where

74Year of birth, hence 1974
LMonth of birth, hence July
71Day of birth, 31 (71-40)

 

The output is 31/07/1974 so the output is in dd/mm/yyyy format

Vijay_A_Verma
Super User
Super User

Please post the sample strings on which this function operates. Please post as text not as picture. You can press table button in the editor to post table as well. 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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 Kudoed Authors