Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
asgerlarsen
Frequent Visitor

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 Table, meaning they are filtering the Sales table and not the other way around.
  • There is no direct relation between the Product and Customer table.

asgerlarsen_0-1697531021890.png

Picture for illustration, not actually my datamodel.


I want to create a measure that counts the number of Holding Companies, a dimension with lower granularity than the customer_key dimension.

 

Here are the problems:

  • Since the Product and Customer tables don't filter each other, the above measure will not slice correctly in the contex of the Product table dimensions and will end up showing the total count of Holding Companies.
  • The sales table contains billions of rows, because of this, I have to use either direct query or mixed storage mode.
  • Creating calculated columns in the fact table will drastically reduce the performance of the report, so I want to avoid doing this.
  • Futhermore, I want to avoid using bi directional relationships since this will also impact performance immensly.

Under these restrictions, is it possible to write the Holding Company Count measure that will slice the correctly on the product dimensions?

2 ACCEPTED SOLUTIONS
asgerlarsen
Frequent Visitor

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.

View solution in original post

OwenAuger
Super User
Super User

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

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

3 REPLIES 3
OwenAuger
Super User
Super User

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

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

I did some testing, and it seems like the 'related pattern' performed twice as good in my senario!

After clearing cashe in the desktop file, I ran the performance analyser and got these two results:

asgerlarsen_0-1697540091280.png


The 'Related pattern' uses your sugestion of SUMMARIZE alongside SUMX:

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

While the 'Crossfilter' uses the CROSSFILTER function:

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

I have marked your suggestion as the a solution.

asgerlarsen
Frequent Visitor

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.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.