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.
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.
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.
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.
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