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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
ca-traveler
Regular Visitor

Convert Excel Formula To Power Query

Hello all,

 

Can someone please help me convert this to power query? I keep getting the token literal expected error. I have googled everywhere and cannot figure the result out. I really appreciate any help! Thanks in advance!

 

IF((OR([Evaluation Status]='Reviewed',[Evaluation Status]='Finalized')*AND([Days Past POP End Date]>=121))'Delinquent',IF(AND([Evaluation Status]='Rated',[Days Past POP End Date]>=91),'Very Late',IF((OR([Evaluation Status]='Initiated',[Evaluation Status]='Drafted'))*AND[Days Past POP End Date]>=31)),'Late','NA')))

4 ACCEPTED SOLUTIONS
Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

Hi @ca-traveler - when you add a column Power Query, you need to use the following syntax for nest if with or + and conditions:

if ( [ColumnName1] = "text1" or [ColumnName1] = "text" ) 
    and [ColumnName2] >= 121 
    then "Result1" else
if  [ColumnName1] = "text3"  
    and [ColumnName2] >= 91 
    then "Result2" else
    "N/A"

Here is a good resource to learn more: IF Statements in Power Query M (Incl Nested IFs, OR, AND) (gorilla.bi) 

View solution in original post

tackytechtom
Super User
Super User

Hi @ca-traveler ,

 

Does this seem to be about right? 🙂

 

tackytechtom_0-1699391044863.png

 

Here the M code for the query:

tackytechtom_1-1699391077521.png

 

if ( [Evaluation Status] = "Reviewed"    or 
     [Evaluation Status] = "Finalized" ) and 
     [Days Past POP End Date] >= 121 then "Delinquent" 
else if [Evaluation Status] = "Rated" and [Days Past POP End Date] >= 91 then "Very Late" else if ( [Evaluation Status] = "Initiated" or [Evaluation Status] = "Drafted" ) and [Days Past POP End Date] >= 31 then "Late" else "NA"

 

Let me know if this helps 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

Awesome, thanks Tom! 🙂

View solution in original post

Awesome, thanks Daryl!

 

Trent

View solution in original post

4 REPLIES 4
tackytechtom
Super User
Super User

Hi @ca-traveler ,

 

Does this seem to be about right? 🙂

 

tackytechtom_0-1699391044863.png

 

Here the M code for the query:

tackytechtom_1-1699391077521.png

 

if ( [Evaluation Status] = "Reviewed"    or 
     [Evaluation Status] = "Finalized" ) and 
     [Days Past POP End Date] >= 121 then "Delinquent" 
else if [Evaluation Status] = "Rated" and [Days Past POP End Date] >= 91 then "Very Late" else if ( [Evaluation Status] = "Initiated" or [Evaluation Status] = "Drafted" ) and [Days Past POP End Date] >= 31 then "Late" else "NA"

 

Let me know if this helps 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Awesome, thanks Tom! 🙂

Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

Hi @ca-traveler - when you add a column Power Query, you need to use the following syntax for nest if with or + and conditions:

if ( [ColumnName1] = "text1" or [ColumnName1] = "text" ) 
    and [ColumnName2] >= 121 
    then "Result1" else
if  [ColumnName1] = "text3"  
    and [ColumnName2] >= 91 
    then "Result2" else
    "N/A"

Here is a good resource to learn more: IF Statements in Power Query M (Incl Nested IFs, OR, AND) (gorilla.bi) 

Awesome, thanks Daryl!

 

Trent

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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