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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
karlk
Advocate I
Advocate I

Including a measure in a visual creates a cross join due to relationships in model

Hi,

I have Power BI report with the following data model:

 

Relationship IssueRelationship Issue

 

The definition of the Total Sales measure is: Totol Sales = SUM(Sales[Order Total])

 

When I create a table visual with either Customer Name and Discount or Customer Name and Total Sales the output is as expected:

 

Customer and Discount % - OK
  
Customer NameDiscount %
Customer 15.00%
Customer 17.50%
Customer 110.00%
Customer 22.00%
Customer 24.00%
Customer 25.50%
Customer 29.00%

 

Customer and Total Sales - OK
  
Customer NameTotal Sales
Customer 15520
Customer 26000
 11520

 

I try and create a table visual with Customer Name, Discount % and Order No (from Sales) Power BI gives me an error saying it can't display the data because it can't determine the relationship between two or more fields.  This is fine and and I understand that it's behaving correctly.

 

However, when I create a table visual with Customer Name, Discount % and Total Sales (measure) the output looks like this:

 

Customer, Total Sales and Discount % - NOT OK
   
Customer NameDiscount %Total Sales
Customer 12.00%5520
Customer 14.00%5520
Customer 15.00%5520
Customer 15.50%5520
Customer 17.50%5520
Customer 19.00%5520
Customer 110.00%5520
Customer 22.00%6000
Customer 24.00%6000
Customer 25.00%6000
Customer 25.50%6000
Customer 27.50%6000
Customer 29.00%6000
Customer 210.00%6000
  11520

 

Power BI seems to have cross joined Customer and Customer Discount in order to calculate the measure.  What I would like to know is:

1.  Why?  Is it to do with the context transition from row context to filter context when calling the measure?

2.  How can I practically avoid this situation.  

 

Any help is appreciated.

 

Thanks

 

Karl

1 ACCEPTED SOLUTION
karlk
Advocate I
Advocate I

Hi,

 

Thanks for your comments.  I've solved the problem using the Performance Analyzer in Power BI to get the DAX.

 

It ran:

EVALUATE
    SUMMARIZECOLUMNS(
        'Customer'[Customer],
        'Customer Discount'[Valid From Date]
        "Total Sales", '*** Measures ***'[Total Sales]
    )

 

So, this was effectively a cross join between Customer and Customer Discount with a filter that removes rows from the result where [Total Sales] returned BLANK.  However the definition of [Total Sales] would never return BLANK because its result is only filtered by Customer, not Customer and Customer Discount.  Because [Total Sales] would never return BLANK it does not remove rows from the result so the extra rows produced by the cross join remain.

 

Customer, Total Sales and Discount % - NOT OK
   
Customer NameDiscount %Total Sales
Customer 12.00%5520
Customer 14.00%5520
Customer 15.00%5520
Customer 15.50%5520
Customer 17.50%5520
Customer 19.00%5520
Customer 110.00%5520
Customer 22.00%6000
Customer 24.00%6000
Customer 25.00%6000
Customer 25.50%6000
Customer 27.50%6000
Customer 29.00%6000
Customer 210.00%6000
  11520

 

In summary the context of the measure wasn't compatible with the context of the visual.

 

Thanks

 

Karl

View solution in original post

3 REPLIES 3
karlk
Advocate I
Advocate I

Hi,

 

Thanks for your comments.  I've solved the problem using the Performance Analyzer in Power BI to get the DAX.

 

It ran:

EVALUATE
    SUMMARIZECOLUMNS(
        'Customer'[Customer],
        'Customer Discount'[Valid From Date]
        "Total Sales", '*** Measures ***'[Total Sales]
    )

 

So, this was effectively a cross join between Customer and Customer Discount with a filter that removes rows from the result where [Total Sales] returned BLANK.  However the definition of [Total Sales] would never return BLANK because its result is only filtered by Customer, not Customer and Customer Discount.  Because [Total Sales] would never return BLANK it does not remove rows from the result so the extra rows produced by the cross join remain.

 

Customer, Total Sales and Discount % - NOT OK
   
Customer NameDiscount %Total Sales
Customer 12.00%5520
Customer 14.00%5520
Customer 15.00%5520
Customer 15.50%5520
Customer 17.50%5520
Customer 19.00%5520
Customer 110.00%5520
Customer 22.00%6000
Customer 24.00%6000
Customer 25.00%6000
Customer 25.50%6000
Customer 27.50%6000
Customer 29.00%6000
Customer 210.00%6000
  11520

 

In summary the context of the measure wasn't compatible with the context of the visual.

 

Thanks

 

Karl

Tad17
Solution Sage
Solution Sage

Hey @karlk 

 

It looks like you either need another measure, column, or table to relate order total and discount. Commenting mainly so I can see your desired result as mentioned by @JustJan  so I can further assess your problem and help in what way I can.

JustJan
Responsive Resident
Responsive Resident

Hi Karl, 

 

What would the desired result look like? There is also a Discount% in your Sales table.

 

At the moment you ask PBI to show all rows from the customer discount table for a customer and to show the total sales (measure) for each line. 

 

Jan 

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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