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
Anonymous
Not applicable

How to calculate the ratio of SUM of Total Employee Divide by  Sum of Total Plan by each department

Hi everyone, i would like to find the ratio of How to calculate the ratio of SUM of Total Employee divide by the Sum of Total Plan by each department. Can i know what should i type inside the Powerbi new column using DAX.

 

I have shared the excel spreadsheet on google drive. (H and I column are the result i am looking for 

 

https://docs.google.com/spreadsheets/d/1cPOLgBYqttGg2wH-MYQli3mt2p5NiWgE/edit?usp=sharing&ouid=10579...

 

 

This is what i have added in my Powerbi column code and it doesnt work

Ratio on Total Employees/Employees by Department (Plan) = TargetEmployees[Total Plan] / SUM (TargetEmployees[Total Plan]), COUNT(Distinct [Department/Section])
1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

Can you try this code:

Total Plan ratio =
VAR _total =
    SUMX( ALL( 'Table' ), [Total Plan] )
VAR _subtotal =
    SUM( 'Table'[Total Plan] )
RETURN
    DIVIDE( _total, _subtotal )

result:

vchenwuzmsft_0-1641805338604.png

I had not created any columns.

ALL( ) is used  to remove all filters on the table. SUMX() and SUM() function you can refer here.

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

8 REPLIES 8
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

Can you try this code:

Total Plan ratio =
VAR _total =
    SUMX( ALL( 'Table' ), [Total Plan] )
VAR _subtotal =
    SUM( 'Table'[Total Plan] )
RETURN
    DIVIDE( _total, _subtotal )

result:

vchenwuzmsft_0-1641805338604.png

I had not created any columns.

ALL( ) is used  to remove all filters on the table. SUMX() and SUM() function you can refer here.

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Anonymous
Not applicable

Thank you for your code. It works perfectly. 😀

Anonymous
Not applicable

The issue i faced is that Department type is text and i am not unable to use numbers to divide by text. Any help is appreciated. Thanks!

@Anonymous , measure which can think of this

 

Plan M= calculate( sum(TargetEmployees[Total Plan] ), allselected())

 

Future M= calculate( sum(TargetEmployees[Future Plan] ), allselected())

 

Future M= calculate( distinctcount(Table[Department/Section]) , allselected())

 

These will give you total you needed

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hello amitchandak, i have tried your method and it doesnt work. 

NoDepartment CodeDepartment/SectionDesignationTotal PlanFuture PlanDifference
1Administration1GeneralGeneral Manager770
2Administration2GeneralAssistant  Manager000
3Administration3GeneralSenior Manager000
4Finance1FinanceFinance Manager110
5Finance2FinanceAssistant Financial Manager220
6Finance3AccountingAccounting Manager000
7Finance4AccountingAssistant Accounting Manager110
8Finance4AccountingAccounting Supervisor10-1
9Production1SewingSewing Technician Supervisor000
10Production2SewingSewing Technician Leader110
11Production2SewingSewing Technician 10-1
12Production2SewingSewing  Admin30-3
13Production3SewingSewing  Admin10-1
14Production4FinishingFinishing QC Supervisor70-7
15Production4FinishingFinishing QC Leader540-54
16Production4FinishingOperator12102
17Production4FinishingOperator12102
18Production4FinishingOperator45243
19Production4FinishingOperator563026
20Production4FinishingOperator110-9

 

 

 

If you look carefully at the excel file i have provided. I want column H and I to sum (Total Plan) / Total Plan based on their department level. For eg. General. The total plan value is 205, and my SUM of department (General) is 7. The ratio i will be getting is 29.28.

 

Another example, Finishing department. The total plan value is 205, and my department(Finishing) is 187. The ratio i will be geting is 205/187 = 10.9

 

How to get 187?  (7 + 54 + 12 + 12 + 45 + 56 + 1) 

 

@Anonymous , Check if the attached file can help

 

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

I understand your method of working. Seems like it is something i am looking for.

Javierphang_0-1641453001084.png

 

Javierphang_1-1641453638905.png

 

 

i have encountered some error when i calculate using my powerbi file. I copied exactly the code you have provided for me. Any advise?

 

This is my code: 

Sub Total = CALCULATE(SUM(TargetEmployees[Total Plan]), filter(ALLSELECTED(TargetEmployees), [Department/Section] =max([Department/Section])))
 
 
Anonymous
Not applicable

Can you kindly explain what is your calculated measures are doing as well as the need to create a new column in the data tab. Thanks.

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.