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,
I want to create a DAX formula that calculates the average price of product category.
I have the following SALES table, I want DAX to sum the prices for each category and divide it by the number of category present in my dataset.
Mathematically, it will be like this:
Sum of Clothing = 47
Sum of Electronics = 1300
Sum of Home = 250
Average by Category = 532.33
If want to filter from another table for one category the sum is the same as the average because it will divide by one.
Thank you
Solved! Go to Solution.
Try something like:
AVERAGEX (
VALUES ( SALES[Category] ),
CALCULATE ( SUM ( SALES[Price] ) )
)
VALUES gives a distinct list of categories.
AVERAGEX then iterates over this list of categories and calculates the sum of prices for each.
You need the CALCULATE statement there to turn the row context that you're on into a filter context on the table. If you leave it out it will just return the total price for the whole table.
Once it has a sum for each category averagex divides by the number of categories.
Hi,
Please follow below steps
1. Create a measure with below Dax
I have attached solution in sample file and uploaded on Sharepoint
https://onedrive.live.com/?cid=9429FE789841BAAD&id=9429FE789841BAAD%21106&parId=root&o=OneUp
Please confirm if the solution works..!!
Hi,
Please follow below steps
1. Create a measure with below Dax
I have attached solution in sample file and uploaded on Sharepoint
https://onedrive.live.com/?cid=9429FE789841BAAD&id=9429FE789841BAAD%21106&parId=root&o=OneUp
Please confirm if the solution works..!!
Try something like:
AVERAGEX (
VALUES ( SALES[Category] ),
CALCULATE ( SUM ( SALES[Price] ) )
)
VALUES gives a distinct list of categories.
AVERAGEX then iterates over this list of categories and calculates the sum of prices for each.
You need the CALCULATE statement there to turn the row context that you're on into a filter context on the table. If you leave it out it will just return the total price for the whole table.
Once it has a sum for each category averagex divides by the number of categories.
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 |
|---|---|
| 19 | |
| 11 | |
| 9 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 35 | |
| 32 | |
| 20 | |
| 12 | |
| 10 |