Search code examples
ssasmdx

Why use a CROSSJOIN when it seems to be implied?


What is the difference between the following two, and which is preferred over the other?

CROSSJOIN(
    [Team].[Hierarchy].[Conference].[NFC],
    {[Team].[Name].[Name].[Detroit Lions], [Team].[Name].[Name].[Minnesota Vikings]}
    )

And:

(
    [Team].[Hierarchy].[Conference].[NFC],
    {[Team].[Name].[Name].[Detroit Lions], [Team].[Name].[Name].[Minnesota Vikings]}
    )

It seems any sets supplied within a tuple are automatically crossjoined, so why the need for the CROSSJOIN` keyword/function? Is it correct to say that the following three are the same?

CROSSJOIN({}, {}, ...) == ({}, {}, ...) == {} * {} * ...

Solution

  • There is no diffrence between the above two statements. However in the last statement

    CROSSJOIN({}, {}, ...) == ({}, {}, ...) == {} * {} * ...

    the last part "({}, {}, ...) == {} * {} *" is not necessarily true. When you write "{} * {}" it only exist if both sets (represented by {}) are same in dimensonility and hierarchility. For details refer Dimensionality and hierarchility