If you ever created any calculations in your cube or in an MDX query that uses division, you've probably run into the issue of dividing by zero (0) or NULL. Dividing by 0 or NULL will show the ugly -1.#INF when browsing your cube from Excel. But being the good developer you are, you don't want your end users to see that. So in order to gracefully handle dividing by 0 or NULL, we can do the following to prevent -1.#INF from exposing its ugly face to your company's executives:
MEMBER [Measures].[NullValuePerUnit] AS Null
MEMBER [MEMBER_NAME] AS
iif([Measures].[Production]=0 OR ISEMPTY([Measures].[Production]),[Measures].[NullValuePerUnit],
[Measures].[Usage] * 1000.0/[Measures].[Production])
By using an IIF statement, we can show NULL if our calculation attempts to divide by zero or NULL, which looks a lot better than showing -1.#INF in a spreadsheet or NaN on your report.
Thanks for posting this. I just used this as an example when creating a calculated member for one of our clients. I had the check for 0, but didn't have the ISEMPTY check. I'm processing the cube right now, so I'll keep my fingers crossed. :)