cancel
Showing results for
Did you mean:
Roman New Member

## Lab2: IF Function Instead Divide

At the end of Lab2, the latests questions, the course proposes a DAX expressions to calculate some needed measures, but on Units instead of Revenue.

The question is: why to use the IF Function for controlling possibles zero errors if after uses the DIVIDE Function?

I see the IF Function affects the numerator, not the denominator; 0 value divided by any value is 0.

Thank you,

Román

5 REPLIES 5 Super User

## Re: Lab2: IF Function Instead Divide

Without knowing the exact question (its been a while since I took part in this course), I would ask if there was a second part to the information. While the DIVIDE function deals with zeros, IF can create other options.

Just grasping at straws.

It could just be that the course facilitator was not as familiar with the DIVIDE function. I prefer to use it over IF when given the opportunity.

Proud to be a Datanaut! jonsan21
Power BI Team

## Re: Lab2: IF Function Instead Divide

Hello!

the formula

IF([Total VanArsdel Units]=0,0,DIVIDE([Total VanArsdel Units],[Total Units],0))

simply make sure that when the "Total VanArsdel Units" is zero, the result returned is zero, instead of having to execute the DIVIDE function.

ekwan Frequent Visitor

## Re: Lab2: IF Function Instead Divide

Hi, zero divided by zero is actually undefined (not 0 as you state) and would probably error out on calculation.  The IF Function prevents a situation of 0 / 0 from being calculated.

Hope this helps. Super User

## Re: Lab2: IF Function Instead Divide

I believe if you re-read that you will see that the IF statement is defining it at 0 for the sake of the visualization so that it doesn't show an error or infinity.

Proud to be a Datanaut!

Highlighted

## Re: Lab2: IF Function Instead Divide

Hi,

in DAX, when you divide a number by zero, DAX usually returns the special value infinity.

In the very special case of 0 divided by 0 (or infinity divided by infinity), DAX returns the special NaN (not a number) value.

Got this from the latest book by "The Italians": The Definitive Guide to DAX

Best regards,

Dominik.