The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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
@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)))
User | Count |
---|---|
25 | |
10 | |
8 | |
7 | |
6 |
User | Count |
---|---|
32 | |
12 | |
10 | |
10 | |
9 |