Forum Discussion
gpillai99
4 years agoFrequent Visitor
AddColumns with Summarize
Hi all Newbie here looking for some guidance. I'm trying to figure out what is the best DAX approach in solving the following problem. Any help from experts in this community is much appreciated. ...
- 4 years ago
Try this solution.
1. Data model:
2. Measures:
Billable Hours = SUM ( LaborHours[Billable Hours] ) Non-Billable Hours = SUM ( LaborHours[Non-Billable Hours] ) Allocated Labor Cost = VAR vBaseTable = ADDCOLUMNS ( SUMMARIZE ( LaborHours, Customer[Customer ID], Employee[Employee ID], Employee[Labor Cost] ), "@CustomerHours", [Billable Hours] + [Non-Billable Hours] ) VAR vEmpHoursTable = ADDCOLUMNS ( vBaseTable, "@EmployeeHoursTotal", CALCULATE ( [Billable Hours] + [Non-Billable Hours], ALL ( Customer ) ) ) VAR vPercentTable = ADDCOLUMNS ( vEmpHoursTable, "@Percent", DIVIDE ( [@CustomerHours], [@EmployeeHoursTotal] ) ) VAR vAllocationTable = ADDCOLUMNS ( vPercentTable, "@Allocation", [@Percent] * Employee[Labor Cost] ) VAR vResult = SUMX ( vAllocationTable, [@Allocation] ) RETURN vResult3. Create visual using Customer[Customer ID]:
- 4 years ago
Yes, this is very clear and works perfectly. Thanks!
DataInsights
4 years agoSuper User
Try this solution.
1. Data model:
2. Measures:
Billable Hours = SUM ( LaborHours[Billable Hours] )
Non-Billable Hours = SUM ( LaborHours[Non-Billable Hours] )
Allocated Labor Cost =
VAR vBaseTable =
ADDCOLUMNS (
SUMMARIZE (
LaborHours,
Customer[Customer ID],
Employee[Employee ID],
Employee[Labor Cost]
),
"@CustomerHours", [Billable Hours] + [Non-Billable Hours]
)
VAR vEmpHoursTable =
ADDCOLUMNS (
vBaseTable,
"@EmployeeHoursTotal", CALCULATE ( [Billable Hours] + [Non-Billable Hours], ALL ( Customer ) )
)
VAR vPercentTable =
ADDCOLUMNS (
vEmpHoursTable,
"@Percent", DIVIDE ( [@CustomerHours], [@EmployeeHoursTotal] )
)
VAR vAllocationTable =
ADDCOLUMNS ( vPercentTable, "@Allocation", [@Percent] * Employee[Labor Cost] )
VAR vResult =
SUMX ( vAllocationTable, [@Allocation] )
RETURN
vResult
3. Create visual using Customer[Customer ID]:
gpillai99
4 years agoFrequent Visitor
Yes, this is very clear and works perfectly. Thanks!