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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
KylePalardy
Regular Visitor

Calculating with Filters

I am trying to calculate the percentage of work that each employee does on each project. I need the individual hours on each project divided by the total hours from each project. I am getting an error message that there is a calculation error that cannot convert the column with the employee name (LeadDeveloper) to true and false. Im not sure how to fix the dax measure or the columns to properly calculate this.

 

 Screenshot 2026-06-30 151854.png

1 ACCEPTED SOLUTION
jgeddes
Super User
Super User

Consider the example data...

jgeddes_0-1782851311124.png

You can get the % of hours by each lead (indicated here as ABC, DEF, etc.) using the context of the visual and the following measure...

%_Hours_Project = 
DIVIDE(
    CALCULATE(SUM('Table'[Hours])),
    CALCULATE(SUM('Table'[Hours]), ALLEXCEPT('Table', 'Table'[ProjectCode])),
    0
)

To get this result...

jgeddes_1-1782851394734.png

 





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

Proud to be a Super User!





View solution in original post

2 REPLIES 2
ibj295
New Member

I split it into three simple measures. Instead of filtering manually, I let the visual's row context (EMP + Project) handle the base calculation, then used ALL(P_data[EMP]) to remove just the employee filter so I get the project's total across everyone:

Total_Hrs = SUM(P_data[Actual_Hrs])

Project Hrs = CALCULATE([Total_Hrs], ALL(P_data[EMP]))

%_of_Hours_by_EMP = DIVIDE([Total_Hrs], [Project Hrs], -1)

 

  • Total_Hrs — simple sum, picks up the current EMP + Project from the visual's row context.
  • Project Hrs — ALL(P_data[EMP]) clears the employee filter only (keeping Project), so this returns the total hours logged on that project by everyone.
  • %_of_Hours_by_EMP — DIVIDE with a -1 fallback, so if a project ever has zero total hours, the measure returns -1 instead of erroring or blanking out (easy to spot as an outlier).

 

Result:

EMP Project Total_Hrs Project Hrs %_of_Hours_by_EMP

ibj295_0-1782969505899.png

 

Each employee's share of a project's total hours now adds up to 100% per project as expected.

 

jgeddes
Super User
Super User

Consider the example data...

jgeddes_0-1782851311124.png

You can get the % of hours by each lead (indicated here as ABC, DEF, etc.) using the context of the visual and the following measure...

%_Hours_Project = 
DIVIDE(
    CALCULATE(SUM('Table'[Hours])),
    CALCULATE(SUM('Table'[Hours]), ALLEXCEPT('Table', 'Table'[ProjectCode])),
    0
)

To get this result...

jgeddes_1-1782851394734.png

 





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

Proud to be a Super User!





Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors
Top Kudoed Authors