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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Converting Excel Formula to M Query Language

Hello, I am new to M query language, however I have need to covert a fairly complex excel formula into M.  I’m not looking to have the formula written for me, but if there are any tips, pointers, or similar examples out there that would help me get to started, I would really appreciate it.  Are there any general strategies for how to convert a formula from Excel into M?

 

The formula is designed to calculate an individual’s retirement eligibility date using a set of encoded business rules and 4 variables: Occupational Series Number, Birth Date, Employee Start Date, and Retirement Plan Code.  The formula uses the excel functions of MIN, MAX, YEAR, VLOOKUP, and nested IF statements that go several layers deep.  Below is the formula for reference.  Thanks so much for any assistance.

 

=IF(OCCUPATIONAL SERIES NUMBER=1811,IF(IF((EMPLOYEE START DATE+365.25*25)<=(BIRTH DATE+365.25*50),(EMPLOYEE START DATE+365.25*25),IF((BIRTH DATE+365.25*50)>=(EMPLOYEE START DATE+365.25*20),(BIRTH DATE+365.25*50),(EMPLOYEE START DATE+365.25*20)))<=(BIRTH DATE+365.25*57),IF((EMPLOYEE START DATE+365.25*25)<=(BIRTH DATE+365.25*50),(EMPLOYEE START DATE+365.25*25),IF((BIRTH DATE+365.25*50)>=(EMPLOYEE START DATE+365.25*20),(BIRTH DATE+365.25*50),(EMPLOYEE START DATE+365.25*20))),(BIRTH DATE+365.25*57)),IF(RETIREMENT PLAN CODE="CSRS",MIN(MAX(BIRTH DATE+55*365.25,EMPLOYEE START DATE+30*365.25),MAX(BIRTH DATE+60*365.25,EMPLOYEE START DATE+20*365.25),MAX(BIRTH DATE+62*365.25,EMPLOYEE START DATE+5*365.25)),IF(RETIREMENT PLAN CODE="FERS",MIN(MAX(BIRTH DATE+VLOOKUP(YEAR(BIRTH DATE),{1920,55;1921,55},2,FALSE)*365.25,EMPLOYEE START DATE+30*365.25),MAX(BIRTH DATE+60*365.25,EMPLOYEE START DATE+20*365.25),MAX(BIRTH DATE+62*365.25,EMPLOYEE START DATE+5*365.25)),"Unavailable")))

1 REPLY 1
Anonymous
Not applicable

@Anonymous, 

For MIN and MAX, you can use List.Min() and List.Max() in M. For YEAR, use Date.Year(). There is no equivalent function in M , but you can use Merge Queries transformation in Query Editor to pull in the look up column. 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.