Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi all,
I am trying to optimize a measure for excess stock. The old way of doing it was a lot of different measures being used in other measures, that were used in other measures etc. This was very slow, and I am using VAR to do it in one measure. The last part of the measure is a Hasonefilter / SUMX in order to sum the measure per row and get the "correct" total.
ISSUE:
When I do this in one measure using VAR, it does not sum in the totals, but when I do it in two different measure, where I put the Hasone / SUMX part in a seperate measure, it does it correctly. QUESTION: Can I fix this so I can keep only one measure?
MEASURES:
Measure that does not sum:
Solved! Go to Solution.
Hi, @Anonymous
Variables can be used anywhere, however, their result might not be always the same. Because they are evaluated in the context in which they are written.
Caution When Using Variables in DAX and Power BI
You can also refer to this similar thread.
Different results depending on dax in measure vs. same dax in variable
@mahoneypat wrote:
When calculated as a variable first it is in the evaluation context of the visual. Putting the variable inside the CALCULATE(variable, FILTER(... does not recalculate the expression in the desired new evaluation context.
Best Regards,
Community Support Team _ Eason
Hi, @Anonymous
Variables can be used anywhere, however, their result might not be always the same. Because they are evaluated in the context in which they are written.
Caution When Using Variables in DAX and Power BI
You can also refer to this similar thread.
Different results depending on dax in measure vs. same dax in variable
@mahoneypat wrote:
When calculated as a variable first it is in the evaluation context of the visual. Putting the variable inside the CALCULATE(variable, FILTER(... does not recalculate the expression in the desired new evaluation context.
Best Regards,
Community Support Team _ Eason
Please provide sanitized sample data that fully covers your issue.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 20 | |
| 10 | |
| 9 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 32 | |
| 31 | |
| 18 | |
| 12 | |
| 11 |