Sunday, February 26, 2012

exists vs nonempty

the AS2005 documentation states that nonemptycrossjoin is deprecated and exists or nonempty should be used instead. i am a bit confused by the intended usage for these two functions. the documentation says that exits performs what autoexits does. however, autoexits only pertains to attribute from the same dimension. on the other hand, sets from different dimensions can be passed to the exists function. if no measure group is specified, exactly how does exists eliminate tuples? is exists(set_x, set_y) equivalent to nonempty(set_x, set_y)?

this might be a trivial question, but since i pretty new to MDX, i could really use some advice here.

Mosha sums things up pretty well in this posting on his blog:

http://sqljunkies.com/WebLog/mosha/archive/2005/10/11/mdx_functions_as2005.aspx

EXISTS with two parameters does whatever autoexists does. EXISTS with three parameters does something similar to NONEMPTY but with one difference (as far as I understand it): because you can now optionally have nulls from your fact table preserved in measure values you might want to find out which combinations of dimension members exist as rows in a fact table even when their associated measure values are null, and to do this you need to use this overload of EXISTS because NONEMPTY of course removes combinations where measures return null.

HTH,

Chris

|||

I tried to explain this in a little bit more detail here: http://www.sqljunkies.com/WebLog/mosha/archive/2006/10/09/nonempty_exists_necj.aspx

Hope this helps

Mosha

http://www.mosha.com/msolap

No comments:

Post a Comment