Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi - I'm pretty new to Power BI, but I'm using it to bring together data from three sources:
I'm trying to build a Matrix Visualization that shows OT per week by employee, like this:
| EE ID | Wk 1 | Wk 2 | Total |
| AB123 | 0.02 | 0.05 | 1.25 |
| BC234 | 0 | 1.01 | 1.01 |
| CD345 | 3.08 | 1.95 | 9.83 |
I'm using a Matrix visualization because it looks to function much like a pivot table in Excel, and will allow me to do SUM all of the records for a single employee (ROW) for the week (COLUMN). The source data doesn't include a total by week, so I need to use Power BI to automate that calculation (which could be anything from 5 unique entries to 50 unique time entries for a week).
I've gotten to the point where I can get the total by week in the Matrix:
| EE ID | Wk 1 | Wk 2 | Total |
| AB123 | 40.02 | 40.05 | 80.07 |
| BC234 | 39.95 | 41.01 | 80.96 |
| CD345 | 43.08 | 41.95 | 85.03 |
But I'm unsure of how to take this result and get it down to the OT for the week. I can't simply take Total - 80 (40 hours x 2 weeks) because OT is calculated on a weekly basis ONLY on hours over 40. In the example of EE BC234, the total OT should actually be 1.01, not the 0.96 that would result from Total - 80.
So I really need to see if EACH WEEK is over 40 before I can total the OT for the period. The formula needs to operate like this: =IF(VALUE<40,0,(VALUE-40)).
Is there a way to do a calculation like that in a Matrix? Is there a better way to sum all the time entry records ('Time'[hours_actual]) by employee ('Employee'[Employee ID]) for each week ('Payroll'[Week Start])?
Thanks for any assistance or links to resources that might help. Appreciate it!
Try this solution.
Data model:
Measures:
Total Hours = SUM ('Time'[hours_actual] )Total OT =
VAR vBaseTable =
SUMMARIZE ( 'Time', Employee[Employee ID], 'Calendar'[Week End] )
VAR vCalcTable =
ADDCOLUMNS (
vBaseTable,
"@OT",
VAR vTotalHours = [Total Hours]
RETURN
IF ( vTotalHours > 40, vTotalHours - 40 )
)
VAR vResult =
SUMX ( vCalcTable, [@OT] )
RETURN
vResult
In the matrix, use fields from the Calendar and Employee tables, and the measure [Total OT]:
Proud to be a Super User!
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 165 | |
| 132 | |
| 118 | |
| 79 | |
| 53 |