 # Percentage of Employees

Hello,

I am trying to calculate the percentage of employees in Branch with a date slicer. My original data is a lot bigger and has duplicates. Also, I cannot used the grand total here since I will be needing it for another calculation afterwards.

``````My formula to calculate the percentage of employees  is:
% of Employees =
CALCULATE(DIVIDE

(DISTINCTCOUNT(tEmployee[EmpID]),

CALCULATE(DISTINCTCOUNT(tEmployee[EmpID]), ALLSELECTED(tEmployee))),

FILTER(VALUES(tEmployee[Enter Date]),tEmployee[Enter Date] <= MAX(Dates[Date])),

FILTER(VALUES(tEmployee[Leave Date]),tEmployee[Leave Date] >= MIN(Dates[Date])))
`````` %Employees.pbix (131.5 KB)

However, it is not bringing in the correct percentage. Both the branc names and dates are a slicer here and users will be able to select all of the brances or just one branch at a time. I am attaching the file below. Please let me know what I might be doing incorrectly here.

Thank you

Thanks for providing a PBIX file I would suggest using measure branching.

``````% of Employees  v2 =
DIVIDE(
CALCULATE( [Employees], ALLSELECTED( Dates )),
CALCULATE( [Employees],
ALLEXCEPT( tEmployee, tEmployee[Branch Name] )
)
)
``````

1 Like

Thanks for posting your question @supergallagher25. To receive a resolution in a timely manner please make sure that you provide all the necessary details on this thread.

Here is a potential list of additional information to include in this thread; demo pbix file, images of the entire scenario you are dealing with, screenshot of the data model, details of how you want to visualize a result, and any other supporting links and details.

Including all of the above will likely enable a quick solution to your question.

Hello,
I have tried to solve it for you,
I created three measures, first i calculated Total Employees by using distinct count,
then total employees by ignoring all the filters using all(named it as Total Employees (W) as it will always give total number of employees ignoring all the filters) and then we can use it late to find percentage.
Then i created a measure to calculate Total employees in each branch and.
Finally i calculated the percentage by dividing Total Employees(W) and Total Employees in branch.
then in visuals i created table which is shoeing percentages and slicers are also working.
date slicer was not working initially as you have two relationships between your date and employees table and they both are inactive, so you have to choose one relationship as active so that date slicer can work.
I am attaching solved Pbix file and some screenshots.
[%Employees By Branch And Date.pbix|attachment]