Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi,
I'm struggling for hours now.
I have data like this:
Person | ContractHours | SomeRecordNotRelevant |
1 | 20 | 15 |
1 | 20 | 16 |
2 | 30 | 17 |
2 | 30 | 18 |
3 | 10 | 19 |
I need an answer like this:
Person 1 who has 20 hours = 33% (20 out of 20+30+10 total hours)
Person 2 with 30 hours = 50%
Person 3 = 16,7%
So what I tried is a measure like this:
Solved! Go to Solution.
Try using ALL or ALLSELECTED for calculating the grand total hours.
VAR AllHoursOverview =
SUMMARIZE (
ALLSELECTED ( 'Table' );
'Table'[Person];
"Hours"; MAX ( 'Table'[ContractHours] )
)
VAR HoursOverview =
SUMMARIZE ( 'Table'; 'Table'[Person]; "Hours"; MAX ( 'Table'[ContractHours] ) )
VAR HoursPerPerson =
SUMX ( HoursOverview; [Hours] )
VAR GrandTotalHours =
SUMX ( AllHoursOverview; [Hours] )
RETURN
DIVIDE ( HoursPerPerson; GrandTotalHours; 0 )
Try using ALL or ALLSELECTED for calculating the grand total hours.
VAR AllHoursOverview =
SUMMARIZE (
ALLSELECTED ( 'Table' );
'Table'[Person];
"Hours"; MAX ( 'Table'[ContractHours] )
)
VAR HoursOverview =
SUMMARIZE ( 'Table'; 'Table'[Person]; "Hours"; MAX ( 'Table'[ContractHours] ) )
VAR HoursPerPerson =
SUMX ( HoursOverview; [Hours] )
VAR GrandTotalHours =
SUMX ( AllHoursOverview; [Hours] )
RETURN
DIVIDE ( HoursPerPerson; GrandTotalHours; 0 )
Thanks, it works!
I doubt my 4 variables are a clean solution, but I don't know any better atm and it works for now.
User | Count |
---|---|
141 | |
70 | |
69 | |
53 | |
52 |
User | Count |
---|---|
208 | |
94 | |
64 | |
60 | |
57 |