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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric 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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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