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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
nattaya_be
Regular Visitor

How to calculate percent by category per fixed number from reference table

I would like to show percent by department which I have data set for expample below - Name and department. Then I have a reference table how many people by department. I already linked these two tables together. However; I can't find the way to write the calculation to DISTINCTCOUNT name / by number of people in that department (from ref table)

 

Thank you so much. 

 

Table1: data

nattaya_be_0-1686582210196.png

Table2: reference

nattaya_be_1-1686582299048.png

 

1 ACCEPTED SOLUTION

Oh ok, so if I understand correctly, in Table1 you can have "Name" repeated?

Then your measure could be something like this:

Percentage of department =
CALCULATE(
    COUNTA(Table1[Name])/SUM(Table2[Total no. by department]),
    Table2[department]=SELECTEDVALUE(Table1[department])
)

View solution in original post

4 REPLIES 4
poweringthru
Helper I
Helper I

Assuming you want to show percentage of total for each department, and each "Name" has a number, amount or quantity, for example Table1[Name Quantity], the measure could be:

 

 

Percentage of department = 
CALCULATE(
    SUM(Table1[Name Quantity])/SUM(Table2[Total no. by department]),
    Table2[department]=SELECTEDVALUE(Table1[department])
)

 

 

Alternatively, you can add it as a calculated column to Table1 like this:

 

 

Percentage of department = 
DIVIDE(Table1[Name Quantity],RELATED(Table2[Total no. by department]),0)

 

Thank you so much for your help. Sorry to ask more question. Name is text input and may need to distinctcount by department, how to write that to build the Table1[Name Quantity]

Oh ok, so if I understand correctly, in Table1 you can have "Name" repeated?

Then your measure could be something like this:

Percentage of department =
CALCULATE(
    COUNTA(Table1[Name])/SUM(Table2[Total no. by department]),
    Table2[department]=SELECTEDVALUE(Table1[department])
)

Thank you so much. I do appreciate your help

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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