Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
I have a table as follows that I need to sum up all the quantities and apply the sum to the product:
| Sales | ||
| PN | Qty | Total Qty |
| AB | 2 | 5 |
| BA | 4 | 8 |
| BA | 4 | 8 |
| CA | 5 | 5 |
| AB | 2 | 5 |
| AC | 2 | 4 |
| AC | 2 | 4 |
| AB | 1 | 5 |
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 | ||
| PN | Qty | Total Qty |
| AB | 2 | 22 |
| BA | 4 | 22 |
| BA | 4 | 22 |
| CA | 5 | 22 |
| AB | 2 | 22 |
| AC | 2 | 22 |
| AC | 2 | 22 |
| AB | 1 | 22 |
It looks like it is not recognizing the expression "Sales(PN) = Sales(PN)". Is there a way to make the formula work?
Solved! Go to Solution.
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.
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
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.
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Thank you Pat! This worked perfectly.
@Anonymous
please try
Measure = CALCULATE(sum('Table'[Qty]),ALL('Table'))
Proud to be a Super User!
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.