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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
croberts21
Continued Contributor
Continued Contributor

How to calculate overtime in payroll in a matrix?

I'm still pretty new to PBI. I have Free PBI Desktop v2.100.1182 (64 bit free version Dec 2021) on Windows 10. I use an ODBC driver to connect to a Postgresql database server. I use a Remote Desktop connection to connect to another PC that runs PBI. I share the PBI computer with one other person.

 

I have a zip file with a PBIX file with sample data here: https://gilsongraphics-my.sharepoint.com/:u:/p/croberts/EcE6N9xyQfFItDLuzIDqMtoBxjAHXhjRkI_lBXkZk4Xe...

 

The zip file contains two .XLSX files but not the dataset for the department. Do not refresh the data.

 

I have a matrix. On the left is a department number and name (comes from a new column), and under the [+] sign for each department are the employees. Across the top are the "Short Desc" for payroll types which vary, but for this week are: PMLA, REG (regular time), VAC (Vacation), Jury (Jury duty). 

 

One table is EmpTime with these fields:

Empid

Hours (in decimal format)

Startdate (so I can calculate only payroll hours for a given week at a time)

Payrolltype (which is a number and links to a table "PayrollTypes", which gives me the short name of the payroll type).

 

Across the type are Hours summed by PayrollType[ShortDesc].

 

I have searched Microsoft tutorials, youtube videos, and other sites but nothing is really close to the situation I have.

 

Here is some fake data and what I have so far in a matrix.

croberts21_0-1648478967143.png

 

  1. Is a matrix the right thing for this job? 
  2. I need to calculate overtime for each person but only some payroll types will count. PMLA (sick time) will not count towards overtime. REG, VAC, and JURY will count towards overtime.

I have a PBIX file with fake data available. 

Thank you!

 

3 REPLIES 3
V-lianl-msft
Community Support
Community Support

Hi @croberts21 ,

 

Sorry, I'm not sure what you expect. See if this is what you expect

Vlianlmsft_0-1648693929014.png

Measure = CALCULATE(SUM(EmpTimeSheet[Total Hours]),FILTER(EmpTimeSheet,EmpTimeSheet[ptype]<>5031))


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello again.

 

I put your formula into a Measure called PossibleHours. But Power BI won't let me drag PossibleHours to the matrix Columns area. And when I check PossibleHours I get this which is not what I want: 

croberts21_0-1650363445291.png

I would only like on instance of PossibleHours on the far right of the matrix.

 

Here's a new zip file with new PBIX file with supporting Excel files.

https://gilsongraphics-my.sharepoint.com/:u:/p/croberts/EcE6N9xyQfFItDLuzIDqMtoBxjAHXhjRkI_lBXkZk4Xe...

I think I should back up. I first want to calculate a column, call it "PossibleHours", with the sum of hours for payrolltypes 9, 5018, 1 and 6 to see if the person gets overtime. PMLA (5031) does not count towards overtime. Here is my matrix now. If "PossibleHours" is > 40  then the person gets overtime pay based on PossibleHours -40. 

croberts21_0-1648722141939.png

I looked through documentation about the dax SUM function and it only takes one column. Doc here: https://docs.microsoft.com/en-us/dax/sum-function-dax

 

My table fields are here. 

croberts21_1-1648722324181.png

Thank you for your help. I've done at least 6 tutorials but they are far too simple for my case. And this forum and a search engine are my only sources of tech support.

 

I have updated my zip file here with the PBIX file and supporting XLSX data sources: https://gilsongraphics-my.sharepoint.com/:u:/p/croberts/EcE6N9xyQfFItDLuzIDqMtoBxjAHXhjRkI_lBXkZk4Xe...

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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