Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello,
I'm currently working on a dashboard where I need to calculate the average sales within several different departments and I'm struggling with getting the average filtered based on departments.
It's all listed in one large dataset so there's several entries of the employee and department, and so far I keep going in circles where I'm getting wrong values. Currently I've managed to calculate the average sales per employee, but it cannot be filtered to department.
Example of how the dataset looks
Date | Employee | Sale | Department |
01.01 | A | 100$ | Team A |
01.01 | B | 150$ | Team B |
02.01 | A | 90$ | Team A |
02.01 | C | 50$ | Team A |
I tried to set up by using the following
Team A = 120
Team B = 150
but what I get is
Team A = 240
Team B = 150
Total Average = 195
Is there a way I can set up a filter in my equation so that it will filter correctly? Any help is appreciated.
Solved! Go to Solution.
Hi,
This will probably do the trick:
Average_Sales=
AVERAGEX(
VALUES(SalesTable[Employee]),
CALCULATE(SUM(SalesTable[Sale]))
)
You can choose if you want the average for your employee or department (depending on your selected columns).
Hope it helps!
Hi @RenateBK ,
Does the solution provided address your issue, or are you still experiencing the problem? Your feedback is important to the community. If your issue has been resolved, please mark the response as Accepted Solution to help others find it more easily.
Thank you.
Hello, I apologize for the delay, I have accepted the solution now!
Kind regards,
Renate
Hello @RenateBK ,
Kindly use below dax to get desired result.
I hope this helps.
Kindly mark this as solution if this helps, kudos are appreciated.
Cheers.
Neeraj
Thank you for the help, this formula was definitely useful. I haven't learn much about removing filters so I will definitely read more up on this section.
FYI The formula you posted also included employees that had 0 sales registered, but had another column entry which was not supposed to be included in this calculation so I accepted the other solution for this problem:
Average_Sales=
AVERAGEX(
VALUES(SalesTable[Employee]),
CALCULATE(SUM(SalesTable[Sale]))
)
However, I think your formula will serve me very well at another point so again, thank you for your time 🙂
Kind regards, Renate
Hi @RenateBK ,
Please review my response at your convenience to see if it meets your requirements. I have attached the PBIX file for better understanding. If it resolves your issue, please mark it as the accepted solution for the benefit of the community.
Hi @RenateBK ,
Thank you for engaging with the Microsoft Fabric Community. I tested your approach and successfully calculated the correct department-wise average sales. The crucial adjustment was ensuring the measure properly filtered by employee count using DISTINCTCOUNT(Employee), which resolved the previous aggregation issue.
Measure Used:
AverageSalesPerDept =
DIVIDE(
SUM(SalesTable[Sale]),
DISTINCTCOUNT(SalesTable[Employee])
)
Output:
For more details, I’ve attached the .pbix file feel free to check it out.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
This will probably do the trick:
Average_Sales=
AVERAGEX(
VALUES(SalesTable[Employee]),
CALCULATE(SUM(SalesTable[Sale]))
)
You can choose if you want the average for your employee or department (depending on your selected columns).
Hope it helps!
Hello, thank you so much this was what I needed! I tried the same formula, but it failed as I had not included "VALUES(".
If possible could you please explain why that was necessary to use here? I'm quite new with this and looking at the Power BI documentation I don't quite understand why using DISTINCTCOUNT could not solve the issue (without removing filters).
Kind regards, Renate
Hi,
Nice to hear that it works!
DistinctCount() wouldn’t work here, because that just counts the number of unique employees, not their totals. If you try to get the average by doing Sum(sales)/ DistinctCount(Employee), you might get misleading results. For example: total sales = 600, 3 employees = average 200. But is that really the average per employee? Maybe Bob has 500, Stuart 100, and Kevin 0. so the real average of employee totals would be (500 + 100 + 0)/ 3 = 200, but in more complex scenarios (like with multiple layers: employee, team, floor, location) it often breaks and gives wrong insights.
That’s why values() is needed. Values(employee) creates a list of all unique employees in the current context. Then AverageX goes through each of them, calculates their individual total sales, and averages those totals.
It’s different from DistinctCount() that just counts unique values, it doesn’t give you a list to iterate over and sum up sales per employee.
Hope it helps! If you have any further questions please let me know. Happy to help!
Thank you for the explanation, that makes so much sense!
I appreciate the help a lot 🙂
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
57 | |
55 | |
55 | |
37 | |
30 |
User | Count |
---|---|
79 | |
66 | |
45 | |
44 | |
42 |