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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
gpillai99
Frequent 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. 

 

I have a table with that has timesheet data submitted by employees to record their time spent on customers. My goal is to proportionally allocate each employees cost to the respective customer accounts they worked on. The output will simply show two columns Customers and Allocated labour cost. Here is an snapshot of how I'm doing it in excel now. I tried using SummarizeColumns with AddColumns but could not figure out the DAX code. Thanks

 

gpillai99_0-1630848195051.png

 

 

2 ACCEPTED SOLUTIONS
DataInsights
Super User
Super User

@gpillai99,

 

Try this solution.

 

1. Data model:

 

DataInsights_0-1630862101316.png

 

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]:

 

DataInsights_1-1630862153174.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Yes, this is very clear and works perfectly. Thanks!

View solution in original post

2 REPLIES 2
DataInsights
Super User
Super User

@gpillai99,

 

Try this solution.

 

1. Data model:

 

DataInsights_0-1630862101316.png

 

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]:

 

DataInsights_1-1630862153174.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Yes, this is very clear and works perfectly. Thanks!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors