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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Rsanjuan
Helper IV
Helper IV

IF - THEN Calculation

I have two columns....Proposed Budget and Proposed Costs.  I am trying to calculate the gross margin % using this formula:

 

(Proposed Budget - Proposed Costs) / Proposed Budget

 

However, there are rows where Proposed Budget and Proposed Costs have values of 0.  And when 0 is divided by 0, I am getting a NaN error.

 

What would be the correct syntax to only calculate this formula ONLY when Proposed Budget > 0?

 

Thanks!

 

2 ACCEPTED SOLUTIONS
Vvelarde
Community Champion
Community Champion

@Rsanjuan

 

hi, try using Divide Function

 

Result=Divide(Table1[Proposed Budget]- Table1[Proposed Costs], Table1[Proposed Budget],Blank())




Lima - Peru

View solution in original post

geeb
Regular Visitor

You can also use IF([Proposed Budget] > 0, ([Proposed Budget] -[Proposed Costs]) / [Proposed Budget]). This will return a blank if the condition is false.

 

The solution above is nice and clean though.

View solution in original post

2 REPLIES 2
geeb
Regular Visitor

You can also use IF([Proposed Budget] > 0, ([Proposed Budget] -[Proposed Costs]) / [Proposed Budget]). This will return a blank if the condition is false.

 

The solution above is nice and clean though.

Vvelarde
Community Champion
Community Champion

@Rsanjuan

 

hi, try using Divide Function

 

Result=Divide(Table1[Proposed Budget]- Table1[Proposed Costs], Table1[Proposed Budget],Blank())




Lima - Peru

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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