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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Category, Total and percentage

This has been hard to figure out. I think I am close but something is missing. 

In excel this is super easy to do. (Example below).  But Power Bi is a different story. 

 

Power bi pic.JPG

 

In Power BI I have these columns and the department count is counting how many are within each department. It looks something like this:

Employee Name                      Department name                    Department Count:

John                                         Administration                                        2

Frank                                        Administration                                        2

Jane                                          IT                                                            1

Sam                                          Development                                          2

Shane                                       Development                                          2

      

To get the Department count I used the Allexcept function. 

 

What I want to do is now take those numbers, total them and then get the percentage. The problem is when I total them its totaling all the numbers. I want to just total them by departmeent. So the total should be 5. From there, I need to take the the total of one department and divide it by the total of all the departments to get a percentage, for each department. 

 

For example, 

Administration - 2/5 = 40%

IT = 1/5 = 20%

Development 2/5=40%

Total = 100%

 

 

Thanks! 

 

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi  @Anonymous ,

 

Create a measure as below:

Measure = 
var _tab=SUMMARIZE('Table','Table'[Department name],"percent",DIVIDE(CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[Department name])),CALCULATE(COUNTROWS('Table'),ALL('Table'))))
Return
SUMX(_tab,[percent])

And you will see:

v-kelly-msft_0-1616570253042.png

For the related .pbxi file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi  @Anonymous ,

 

Create a measure as below:

Measure = 
var _tab=SUMMARIZE('Table','Table'[Department name],"percent",DIVIDE(CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[Department name])),CALCULATE(COUNTROWS('Table'),ALL('Table'))))
Return
SUMX(_tab,[percent])

And you will see:

v-kelly-msft_0-1616570253042.png

For the related .pbxi file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

themistoklis
Community Champion
Community Champion

@Anonymous 

 

Try the following formula for denominator:

CALCULATE(DISTINCTCOUNT('Table'[Employee Name]), ALL('Table'))

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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