+ Reply to Thread
Results 1 to 6 of 6

Calculate Total Pay Using Pivot Table Calculated Fields or VBA Macro

  1. #1
    Forum Contributor
    Join Date
    02-20-2011
    Location
    Candada
    MS-Off Ver
    Microsoft Office 365
    Posts
    174

    Calculate Total Pay Using Pivot Table Calculated Fields or VBA Macro

    Happy Greetings from wherever you are,
    I have a pivot table that calculates regular and overtime hours worked by each employee on a weekly basis. I would like to know if there is a way of obtaining the Total Pay either by using an Excel pivot table calculated fields or an Excel VBA code to first multiply regular hours by $1.00 and overtime hours by $1.50 and finally adding the regular and overtime pay in a column next to the pivot table. Right now I can accomplish this task by calculating the total pay by multiplying regular hours (REG) by $1.00 dollar and the OT by $1.50 dollar and then summing up Regular Pay and Overtime Pay. The issue that I have with this approach is that as the pivot table adds more data or rows, I have to constantly drag down the formulas in columns G, H and I. I appreciate your shared knowledge and time to help me and others.
    See attachment for better explanations.
    Attached Files Attached Files

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Calculate Total Pay Using Pivot Table Calculated Fields or VBA Macro

    Greetings to you too.
    You probably have the values on a different sheet all calculations show a VALUE error
    You should refer to cells and fill in the values there and name those cells
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Calculate Total Pay Using Pivot Table Calculated Fields or VBA Macro

    You can add Calculated Fields to your pivot table. Here is a step-by-step guide:

    Excel Pivot Table Calculated Field
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Forum Contributor
    Join Date
    02-20-2011
    Location
    Candada
    MS-Off Ver
    Microsoft Office 365
    Posts
    174

    Re: Calculate Total Pay Using Pivot Table Calculated Fields or VBA Macro

    Thank you Mr. AlphaFrog and Keebellah for your help.
    As you can see from the attached sample2, I created a calculated field following the instructions in the contextures website, and the pivot table added 6 columns sum of Sum of Hours
    , Sum of Regular Time Pay, Sum of Hours, Sum of Regular Time Pay, Total Sum of Hours, and Total Sum of Regular Time Pay. However, I get zero for values in Sum of Regular Time Pay, Sum of Regular Time Pay, and Total Sum of Regular Time Pay. The calculated field formula that I used was =Hourtype*1.00. Also, the table in I through K columns gets moved as the calculated fields get added and the formulas in gives me a #VALUE!. What am I doing wrong? Can this be accomplish with a VBA code?
    Thank you so much again.
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Calculate Total Pay Using Pivot Table Calculated Fields or VBA Macro

    I use Excel 2003 which cant use your workbook version with pivot tables. Perhaps someone else will help.

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Calculate Total Pay Using Pivot Table Calculated Fields or VBA Macro

    I cannot help you with the sample you have attached since I do not have the data with which you generate the pivot table.
    You probably entered an incorrect value for calculation the hour. in the first file I noticed that the value was a string, you should use a cell and enter the value there and refer to that cell.
    I think it's the decimal sign entered that is causing you the problem.
    Without data I cannot help you either

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Calculated field using the Grand Total and Values fields of Pivot chart
    By krissysteen in forum Excel Charting & Pivots
    Replies: 8
    Last Post: 02-01-2018, 04:25 AM
  2. VBA code to calculate pivot fields to create calculated field programmatically
    By dougmcc1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-09-2015, 09:18 PM
  3. Replies: 2
    Last Post: 10-26-2015, 06:49 AM
  4. [SOLVED] Pivot table calculated item doesn't calculate on Grand Total
    By nfcascalheira in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 10-27-2014, 08:10 AM
  5. Calculated Fields in a Pivot Table
    By rkrieg in forum Excel General
    Replies: 3
    Last Post: 07-18-2011, 07:45 PM
  6. Pivot Table calculated fields
    By tigertim71 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 05-15-2008, 04:58 AM
  7. Replies: 3
    Last Post: 01-26-2006, 01:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1