Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
RenateBK
Helper I
Helper I

How to calculate average sales based on employees within different departments

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

DateEmployeeSaleDepartment
01.01A100$

Team A

01.01B150$

Team B

02.01A90$Team A
02.01C50$Team A

I tried to set up by using the following

= DIVIDE(SUM(SalesTable[Sales), DISTINCTCOUNT(SalesTable[Department]))
 
What I want to see is the average sales based on department:

Team A = 120

Team B = 150

 

but what I get is

Team A = 240

Team B = 150

Total Average = 195

 

The issue I run into is that in the matrix when I set it up with department and the sales average, it doesn't filter the average based on department, it only gives me the total average at the bottom. 
RenateBK_0-1750237485077.png

Is there a way I can set up a filter in my equation so that it will filter correctly? Any help is appreciated.

2 REPLIES 2
V-yubandi-msft
Community Support
Community Support

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:

 

Vyubandimsft_0-1750258933378.png

 

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.

 

AlexTheGreat
Frequent Visitor

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!

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.