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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
McFly123
New Member

DAX Newbie - Please help!

Hi Gurus!

 

I am just starting out with Dax coding in Bi as part of a project to migrate away from XL for some reports I write....

 

Now something so simple - im struggling with. I am trying to calculate the percentage headcount for each site and add this to a column in a table. So far I have a measure called "Total Headcount" (this works and gives me the total heads for all sites)

 

I then have a table with the following data

 

Site  |   Headcount | % Headcount

A            100

B              20

C              58

 

I am trying to work out the % headcount by using the below DAX:

 

% Headcount = DIVIDE('Sites'[Headcount],[Total Headcount],0)

 

but this returns 100% for all rows. If i remove the measure and add a number like below:

 

% Headcount = DIVIDE('Sites'[Headcount],178,0)

 

it works.....I've had a little look through google and believe i need to calculate using the ALLSELECTED function but i cannot get the syntax right! Can anyone help??

 

Also - Being new, are there any basic guides people could recommend for Dax syntax, coding layout etc.

 

Thanks in advance!

 

Martyn

1 REPLY 1
amitchandak
Super User
Super User

@McFly123 , If head count is a column , try a measure like

divide(sum(Table[Headcount]), calculate(sum(Table[Headcount]), allselected(Table)))

 

 

If headcount is a measure, try measure like
divide(([Headcount]), calculate(([Headcount]), allselected(Table)))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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