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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
zhblack
Regular Visitor

If and formula

I am trying to identify if an item is an outage. An outage is when day 1 is less than 1 and uasge within last year is greater than 1. 

 

= Table.AddColumn(#"Expanded Usage_MRP_K", "Custom", each IF( And(  value([Day1])<1, value([Usage_MRP_K.Usage Within Last Year])>1 ) ,"Outage", "No Outage"))

 

I get the following error message when I enter the above formula. 

 

Expression.Error: The name 'IF' wasn't recognized.  Make sure it's spelled correctly.

1 ACCEPTED SOLUTION
drewlewis15
Solution Specialist
Solution Specialist

The Query Editor uses a syntax called "M" that differs from the syntax used in Excel.  It is also case sensitive.  The below statement should get what you need based on how you wrote your if statement:

 

if [Day1] < 1 and [Usage_MRP_K.Usage Within Last Year] >1 then "Outage" else "No Outage"

 

If you need additional help, the article below is a good reference:

 

https://www.myonlinetraininghub.com/power-query-if-statements

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @zhblack

Modify your formula as drewlewis15's suggestion, it turns out to be right.

Table.AddColumn(#"Changed Type", "Custom", each if [Day1] < 1 and [Usage_MRP_K.Usage Within Last Year] >1 then "Outage" else "No Outage")

6.png

 

Best Reagrds

Maggie

drewlewis15
Solution Specialist
Solution Specialist

The Query Editor uses a syntax called "M" that differs from the syntax used in Excel.  It is also case sensitive.  The below statement should get what you need based on how you wrote your if statement:

 

if [Day1] < 1 and [Usage_MRP_K.Usage Within Last Year] >1 then "Outage" else "No Outage"

 

If you need additional help, the article below is a good reference:

 

https://www.myonlinetraininghub.com/power-query-if-statements

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors