Forum Discussion

tbennett93's avatar
tbennett93
Frequent Visitor
3 years ago
Solved

Am I Using RANKX Incorrectly? It causes a cartesian join across relationships.

When I use RANKX, it seems to cause a cartesian join across a relationship.   Example: FACTtable ColourId Value 1 6 2 2 3 7 4 2 5 1 5 4   DIMtable ColourID C...
  • CNENFRNL's avatar
    3 years ago

    Such a seemingly simple issue involves many intricacies under the hood. Even a seasoned DAX user might be incapable to wrap his head around it.

     

    1. It's NOT rankx() that causes the cartisian product but it's the fact the cartisian product already exists there and those "unreasonable" rows are "accidentally" made visible by your measure.
      Here's a simple way to prove its existence,

      all rows can be made dissapear this way,

       

    2. When you drag columns into a viz functions, they function independently as separate filters; a measure evaluates under the comprehensive effects of all these filters. As long as a measure evaluates any value other than BLANK(), the correspondent row shows.

    3. A reasonable measure can be authored this way


    4. Rankx() is one of the most frequently used and also trickiest functions in DAX. Once you manage to master it, DAX is almost under full control.