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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
hermesgoddess
Frequent Visitor

Add Custom Column with nested IF Not Working

I am trying to create a new column (two actually) that will return the total number of booked rooms Canceled from my database. The total number of booked rooms = number of rooms times number of nights - in my case [NumRms]*[Number of nights]. I also have a status column to find my canceled or no show rooms... [Status]="CXL" and [Status]="no show". If the status is anything except CXL or no show, I need the row to be "0". But my IF formula keeps giving me a Token Else expected. Not sure what I am missing:

 

Untitled picture.png

1 ACCEPTED SOLUTION
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @hermesgoddess,

 

In addition, you can also use DAX to add a new calculate column in your table under Modeling tab in this scenario. The formula below is for your reference. Smiley Happy

 

CANCELED =
IF (
    'Table1'[Status] = "CXL"
        || 'Table1'[Status] = "no",
    'Table1'[Num Rms] * 'Table1'[Number of nights],
    0
)

Note: Just replace 'Table1' with your table name.

 

modeling.PNG

 

Regards

View solution in original post

2 REPLIES 2
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @hermesgoddess,

 

In addition, you can also use DAX to add a new calculate column in your table under Modeling tab in this scenario. The formula below is for your reference. Smiley Happy

 

CANCELED =
IF (
    'Table1'[Status] = "CXL"
        || 'Table1'[Status] = "no",
    'Table1'[Num Rms] * 'Table1'[Number of nights],
    0
)

Note: Just replace 'Table1' with your table name.

 

modeling.PNG

 

Regards

MarcelBeug
Community Champion
Community Champion

Try and replace "then if" by "or ".

 

Are you sure about the double quotes around the "0"?
I would expect just number 0, not text "0".

Specializing in Power Query Formula Language (M)

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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