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
GustavoCamargo
New Member

DAX - Sum with max and filtered data

Hi everyone,

 

I'm struggling with DAX calculation problem as follows:

 

I have a table similar as mentioned below. I want to find a calculation based on summed maximumn value of 'SERVICE_QTY' times 'NET_PRICE'. I should be able to filter the data by Product Line and Model name.

 

PROD_IDPRODUCT_LINEMODEL_NAMENET_PRICESERVICE_QTYSALES
AAAAPRODUCT AMODEL A259.9220
AAAAPRODUCT AMODEL B259.9320
AAAAPRODUCT AMODEL C259.9220
AAAAPRODUCT AMODEL D259.9220
AAAAPRODUCT BMODEL E259.9220
AAAAPRODUCT BMODEL F259.9320
BBBBPRODUCT AMODEL A300.5415
BBBBPRODUCT AMODEL B300.5315
BBBBPRODUCT AMODEL C300.5115
BBBBPRODUCT AMODEL D300.5115
CCCCPRODUCT BMODEL E350.2210
DDDDPRODUCT BMODEL E259.925
DDDDPRODUCT BMODEL F259.935

 

I have created this measure:

 

QTY_PRICE = 
var MaxQty = 
    CALCULATE(max('Table'[QTY]), ALLEXCEPT('Table', 'Table'[PROD_ID], 'Table'[PRODUCT_LINE], 'Table'[MODEL_NAME]))
Return
    CALCULATE(MaxQty * MAX('Table'[NET_PRICE]), 'Table'[SALES] > 5)

 

 

With that I am able to filter the data and calculation by rows is right, however total sum showed is completly wrong...

In the example, it suppose to be 2936 instead of 1400 (image below)

 

question.PNG

 

Any thoughts?

 

Thanks in advance.

 

1 ACCEPTED SOLUTION
V-pazhen-msft
Community Support
Community Support

@GustavoCamargo 

1400 is calculated based on your return using the MAX price * MAX Qty.

 

It is a very common question that why the measure total is not the sum of the previous rows on the table visual. I really suggest you to take a look at the 2 short blogs.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907
https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376 

Best,
Paul

View solution in original post

1 REPLY 1
V-pazhen-msft
Community Support
Community Support

@GustavoCamargo 

1400 is calculated based on your return using the MAX price * MAX Qty.

 

It is a very common question that why the measure total is not the sum of the previous rows on the table visual. I really suggest you to take a look at the 2 short blogs.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907
https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376 

Best,
Paul

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.