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
Hi all,
I'm struggling to find the answer, so hopefully someone here can help me. I feel like it's an easy fix within DAX for a trained eye. 😉
This is an example set I had.
| Store | Matrixcode | Average Revenue | Matrixcode average |
| 1 | A | 10 | 8 |
| 2 | B | 8 | 8 |
| 3 | A | 6 | 8 |
I used this formula to get the column 'Matrixcode average' in the table above:
| Store | Matrixcode | Productcategory | Average Revenue | Matrixcode average |
| 1 | A | Milk | 8 | 17,2 |
| 1 | A | Eggs | 12 | 17,2 |
| 2 | B | Bread | 1 | 3,5 |
| 2 | B | Milk | 6 | 3,5 |
| 3 | A | Cheese | 20 | 17,2 |
| 3 | A | Milk | 16 | 17,2 |
| 3 | A | Bread | 30 | 17,2 |
The issue is that the formula I have averages every single row value.
Example: For stores with matrixcode value A, it add: (8 +12 + 20 + 16 + 30)/5 = 17,2.
What I now want to formula to do is: sum each stores total revenue, and make an average of it.
So: Store 1 = 20, store 3 = 66. The average should get to (20 + 66) / 2 = 43.
How do I alter the formula below to make it so? Is that even possible within this formula?
Solved! Go to Solution.
@Anonymous
Measure =
VAR numerator =
CALCULATE (
SUMX (
ALL ( 'table'[Store] ),
CALCULATE (
SUM ( 'table'[Average Revenue] ),
ALLEXCEPT ( 'table', 'table'[Store], 'table'[Matrixcode] )
)
)
)
VAR denominator =
CALCULATE (
DISTINCTCOUNT ( 'table'[Store] ),
ALLEXCEPT ( 'table', 'table'[Matrixcode] )
)
RETURN
DIVIDE ( numerator, denominator )
Hi @Anonymous
please try
Matrixcode average =
AVERAGEX (
CALCULATETABLE (
'Table',
ALLEXCEPT ( 'Table', 'Table'[Store], 'Table'[Matrixcode] )
),
[Average Revenue]
)
Thank you for replying!
This unfortunately did not succeed, it resulted in similar results.
@Anonymous
Measure =
VAR numerator =
CALCULATE (
SUMX (
ALL ( 'table'[Store] ),
CALCULATE (
SUM ( 'table'[Average Revenue] ),
ALLEXCEPT ( 'table', 'table'[Store], 'table'[Matrixcode] )
)
)
)
VAR denominator =
CALCULATE (
DISTINCTCOUNT ( 'table'[Store] ),
ALLEXCEPT ( 'table', 'table'[Matrixcode] )
)
RETURN
DIVIDE ( numerator, denominator )
Perfect, this worked! Thanks for the reply. I will study the formula to fully understand what you've written 🙂
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.
| User | Count |
|---|---|
| 9 | |
| 5 | |
| 4 | |
| 4 | |
| 3 |
| User | Count |
|---|---|
| 13 | |
| 9 | |
| 9 | |
| 9 | |
| 8 |