Forum Discussion

asgerlarsen's avatar
asgerlarsen
Frequent Visitor
3 years ago
Solved

How do I create a measure that will slice correctly on an indirect table dimensions?

Imagine this: I have 3 tables; 1 Product dimension table, 1 Customer dimension table and 1 Sales fact table. Both the Product and Customer tables have a one directional relationship to the Sales T...
  • asgerlarsen's avatar
    3 years ago

    I have tried the CROSSFILTER() function, and the performance doesn't seem as bad as I feared, so I will consider this problem solved for now.

    I used it in the same way the bi-directional relationship guide illustrates:

     

    Count of Holding Companies =
    CALCULATE(
        DISTINCTCOUNT(Customer[Holding Company]),
        CROSSFILTER(
            Customer[CustomerId],
            Sales[CustomerId],
            BOTH
        )
    )

     

     

    This way, when the Product table filters the Sales table, it will also filter the Customer table in the measure.

  • OwenAuger's avatar
    3 years ago

    It would be interesting to compare the "related distinct count" pattern here.

    It should be logically equivalent to your measure, but I would be interested in how performance compares.

    In this case it would be:

     

    Count of Holding Companies =
    VAR HoldingCompaniesFromSales =
        SUMMARIZE ( Sales, Customer[Holding Company] )
    VAR Result =
        SUMX ( HoldingCompaniesFromSales, 1 )
    RETURN
        Result