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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
PaulaMA
Regular Visitor

Nested IF AND statement

Could anyone help me with this? I keep getting this error message

 

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

 

Table.AddColumn(#"Added Conditional Column1", "Custom", IF (
AND ( [IncidentsPrevMth]-([NoofIncidentsLast12]/12)>0, [IncidentsPrev2ndMth]-([NoofIncidentsLast12]/12)>0),
1,0))

3 REPLIES 3
FreemanZ
Super User
Super User

hi @PaulaMA ,

 

try like:

Table.AddColumn(
    #"Added Conditional Column1",
    "Custom",
    each if  [IncidentsPrevMth]-([NoofIncidentsLast12]/12)>0 and [IncidentsPrev2ndMth]-([NoofIncidentsLast12]/12)>0
    then 1
    else 0
)

j_ocean
Helper V
Helper V

You might want to code custom columns in the GUI custom column editor, this looks like you got it out of advanced editor.

 

The custom column editor has better syntax support and error messages.

mlsx4
Super User
Super User

Hi @PaulaMA 

 

If you are using PQ, you need to change the syntax (you're mixing with DAX):

 

You should do something similar to this (could be some syntax error with parenthesis because of doing it here):

 

 

Table.AddColumn(#"Added Conditional Column1", "Custom", each if ([IncidentsPrevMth]-([NoofIncidentsLast12]/12))>0 and ([IncidentsPrev2ndMth]-([NoofIncidentsLast12]/12))>0 then
1 else 0)

 

 

 I mean, if..then..else for the ifs conditions and the keyword "and" to do the AND

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors