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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Anonymous
Not applicable

@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
Anonymous
Not applicable

@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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.

Top Kudoed Authors