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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors