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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Salauat
Regular Visitor

Matrix total from 2 different tables is incorrect

Hello, 

I will explain very simply. I have two tables with relationship "Model"

Table_A:

  • Col1 - Model (multiple)
  • Col2 - Model name

Table_B:

  • Col1 - Model (unique)
  • Col2 - Unit Price

My table visual shows me total price = unit price * model count, which is calculated correct. But the grand total for all devices is too high. I think here's something wrong with HASONEFILTER expression

My total price formula:

 

 

 

CALCULATE(SUM('Price'[Price]) * COUNTA('Model'[Model name]))

 

 

 

 

Here's sample data screenshot

I couldnt upload image, so I am putting link here - https://ibb.co/HCtdzXP

1.png

6 REPLIES 6
CNENFRNL
Community Champion
Community Champion

Hi, @Salauat , you may try this measure,

Total price =
SUMX (
    DISTINCT ( 'Table_B'[Model] ),
    CALCULATE ( COUNTROWS ( 'Table_A' ) * MAX ( 'Table_B'[Unit Price] ) )
)

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Hello @CNENFRNL . I tried your formula, but anyway overall total is not correct

Salauat_0-1607914041358.png

 

@Salauat Your columns are coming from different tables, show how they are connected, it would be great if you can attach a sample file.

Anonymous
Not applicable

@Salauat  try using HASONEVALUE instead. You can refer the following link which solves the measure totals problem:

https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

 

 

Did I solve your problem?

If yes, then please mark my answer Accepted!

@Anonymous I have tried your solution, but it is not working for me, maybe I typed incorrect formula.

Can you please write a formula for me?

Anonymous
Not applicable

@Salauat , you need to summarize the Measure you have created. The calculated measure for correct total will be as follows:

MeasureTotal =
VAR _sum = SUMMARIZE(TableA, TableA[Model Name], "_value", [Measure])
RETURN
IF(HASONEVALUE(TableA[Model Name]),[Measure],SUMX(_sum, [_value]))
 
Did I answer your problem?
If yes, please mark as Accepted!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.