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! Learn more

Reply
Anonymous
Not applicable

SUMX with FILTER calculation in the same table

I have a table as follows that I need to sum up all the quantities and apply the sum to the product:

Sales  
PNQtyTotal Qty
AB25
BA48
BA48
CA55
AB25
AC24
AC24
AB15

When I try to use the following formula: Total QTY = SUMX(FILTER(Sales, Sales(PN) = Sales(PN)),Sales(Qty)) 

This is what I get where it gives me the total sum of the Qty column:

 

Sales  
PNQtyTotal Qty
AB222
BA422
BA422
CA522
AB222
AC222
AC222
AB122

 

It looks like it is not recognizing the expression "Sales(PN) = Sales(PN)". Is there a way to make the formula work?

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Sales(PN) = Sales(PN) is always true, so all your rows are included in the total.  Please try this expression instead.

 

NewMeasure = CALCULATE(SUM(Sales[Qty]), ALLEXCEPT(Sales, Sales[PN]))

 

To see how it works, just create a blank query, go to Advanced Editor, and replace the text there with the M code below.

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
mahoneypat
Microsoft Employee
Microsoft Employee

Sales(PN) = Sales(PN) is always true, so all your rows are included in the total.  Please try this expression instead.

 

NewMeasure = CALCULATE(SUM(Sales[Qty]), ALLEXCEPT(Sales, Sales[PN]))

 

To see how it works, just create a blank query, go to Advanced Editor, and replace the text there with the M code below.

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Thank you Pat! This worked perfectly.

ryan_mayu
Super User
Super User

@Anonymous 

please try

Measure = CALCULATE(sum('Table'[Qty]),ALL('Table'))

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.

Top Solution Authors