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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
kpeterson
Frequent Visitor

% of a number

So I'm relatively new to power BI I have a table with the following:

 

Generic Employees #

Which Department they are in

Whether or not they have been vaccinated

 

I'd like to create a new table or measure that give me the following:

# of employees in each deparment

# of employees vaccinated by department

% of employees by department

 

I'm somewhat familiar with DAX.

 

Thanks in advance!

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@kpeterson Those are long column names but:

 

# Employees = COUNTROWS('Table'[Generic Employee #])

# Vaccinated = COUNTROWS(FILTER('Table',[Whether or not they have been vaccinated] = "Yes"))

% Of Employees = DIVIDE([# Vaccinated],[# Employees],BLANK())

 

Put those into a table visual along with the column [Which Department they are in]

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @kpeterson  ,

According to your description, I create some data:

v-yangliu-msft_0-1620365319352.png

Here are the steps you can follow:

1. Create calculated table.

New Table =
SUMMARIZE(
    'Table',
    'Table'[Department],
    "of employees in each deparment",CALCULATE(COUNT('Table'[Generic Employees]),FILTER('Table','Table'[Department]=EARLIER('Table'[Department]))),
    "of employees vaccinated by department",CALCULATE(COUNT('Table'[Generic Employees]),FILTER('Table','Table'[Department]=EARLIER('Table'[Department])&&'Table'[vaccinated]="Yes"))
    )

2. Create calculated column.

% of employees by department = DIVIDE('New Table'[of employees vaccinated by department],'New Table'[of employees in each deparment])

3. Result:

v-yangliu-msft_1-1620365319358.png

 

 

Best Regards,

Liu Yang

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

Greg_Deckler
Super User
Super User

@kpeterson Those are long column names but:

 

# Employees = COUNTROWS('Table'[Generic Employee #])

# Vaccinated = COUNTROWS(FILTER('Table',[Whether or not they have been vaccinated] = "Yes"))

% Of Employees = DIVIDE([# Vaccinated],[# Employees],BLANK())

 

Put those into a table visual along with the column [Which Department they are in]

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.