16
Creating and Using Formulas in Pivot Tables This session will cover creating Pivot Tables and look into the use of calculated fields within the pivot table. When the Pivot Table sums information, it makes some assumptions that the calculations should be applied to the total rows. Sometimes, this is a good thing, other times… not so. We will look at a few examples of Pivot Tables with different information and see the effects of using source data calculations as opposed to using calculations within the pivot table. We will start by creating a percentage of completion based on estimated and actual costs by job within a customer. The “SOURCE” file will start with the JOBS table. From the JOBS table, we will pull the job_id which will link all the other data back to the source sheet (very important). To further breakdown the data, we will select the Customer_id from the JOBS table and the original_cost field from the JOBS table. We will also enable criteria to show jobs that do not have a status of “O” for Overhead This Data will provide the basis of our Pivot Table Report. These tables house the basic building blocks for the rest of the data. job_id Column1 Column2 original_cost COMCOST 10 - T&M Client CUSTOMER REC COMCOST - Committed Cost Job 8,000.00 $ 234 10 - T&M Client CUSTOMER REC 234 - default 536,644.00 $ 158 10 - T&M Client CUSTOMER REC 158 - GRAYCLAW 50,000.00 $ 151 10 - T&M Client CUSTOMER REC 151 - TEST FALLOUT 3,321.00 $ 152 10 - T&M Client CUSTOMER REC 152 - Remaining Committed 43,323.00 $ 10 10 - T&M Client CUSTOMER REC 10 - T&M Job 1,500,000.00 $ 105 10 T&M Client CUSTOMER REC 105 ams 10 003 00 $

Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated

  • Upload
    others

  • View
    17

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated

Creating and Using Formulas in Pivot Tables

This session will cover creating Pivot Tables and look into the use of calculated fields within the pivot table. When the Pivot Table sums information, it makes some assumptions that the calculations should be applied to the total rows. Sometimes, this is a good thing, other times… not so.

We will look at a few examples of Pivot Tables with different information and see the effects of using source data calculations as opposed to using calculations within the pivot table.

We will start by creating a percentage of completion based on estimated and actual costs by job within a customer.

The “SOURCE” file will start with the JOBS table. From the JOBS table, we will pull the job_id which will link all the other data back to the source sheet (very important). To further breakdown the data, we will select the Customer_id from the JOBS table and the original_cost field from the JOBS table.

We will also enable criteria to show jobs that do not have a status of “O” for Overhead

This Data will provide the basis of our Pivot Table Report. These tables house the basic building blocks for the rest of the data.

job_id Column1 Column2 original_costCOMCOST 10 - T&M Client CUSTOMER REC COMCOST - Committed Cost Job 8,000.00$ 234 10 - T&M Client CUSTOMER REC 234 - default 536,644.00$ 158 10 - T&M Client CUSTOMER REC 158 - GRAYCLAW 50,000.00$ 151 10 - T&M Client CUSTOMER REC 151 - TEST FALLOUT 3,321.00$ 152 10 - T&M Client CUSTOMER REC 152 - Remaining Committed 43,323.00$ 10 10 - T&M Client CUSTOMER REC 10 - T&M Job 1,500,000.00$ 105 10 T&M Client CUSTOMER REC 105 ams 10 003 00$

Page 2: Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated

We will create a separate query on another worksheet within the workbook to pull the Change Order information for the jobs. This information is stored in the JOB_CHG table. From this table, we will pull the job_id that will be used to reference the job_id from the SOURCE worksheet. We will also pull the field for tot_cost_adj; this field is the COST amount on the General Tab of the Job Cost Change Order Screen Sum the amount of the tot_cost_adj to form a single row total for every job.

We now have two worksheets that contain the data with the original cost amount and the total of the change order costs. A SUMIF equation is used to link this data together.

(SUMIFS were covered in a previous webinar session; please refer to that lesson for mare detail on this function)

job_id Sum of tot_cost_adj10 90,454.00$ 100 940.00$ 1000 27,070.00$ 1001 2,003.79$ 1002 8,500.00$ 1003 5,300.00$ 1006 5,000.00$ 1006A 1,650.00$ 101-03 4,800.50$ 104 8,000.00$ 106 32,000.00$ 112 800.00$ 117 12,000.00$ 122 200.00$ 133 20,000.00$

Page 3: Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated

To Obtain the Revised Estimated Cost Value, we must add the Original Estimated Cost with the Change Order amount(s). This is achieved by adding the values in Column D + E.

On a new worksheet, we will pull the data for Costs to Date. This information is stored in a table named job_history. This query will contain two fields, job_id (as a reference to our SOURCE worksheet) and the sum of the costs field.

We will use a similar SUMIF formula to pull the cost to date data back to the SOURCE sheet.

job_id Sum of costESB (168.00)$ EE123 500.00$ 129 1,100.00$ PIT3 37.00$ 3 2,722.82$ NSCG 80,000.00$ ANNARBOR 1,049.52$ 1006A 1,488.58$ JTA161 6,700.00$ 106 64,625.34$ EE126 100.00$ 133 4,116.00$ 152 10,700.00$ 20074 9,487.65$ KIMMEL 94,000.00$

Page 4: Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated

Create a column for remaining costs (or over/under revised estimated costs). This formula is the value in column F – E.

Finally, we will create a column for the Percentage of completion based on costs to date compared to revised estimated costs. This formula is the value in Column G divided by the value in Column F.

OK, so we have our data set to create the pivot table.

From the INSERT tab on the toolbar, Select Pivot Table. Make sure you are clicked on a cell within the Table that has the returned data.

Page 5: Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated

This Pivot Table will have the Customer and Job in the ROW Labels section, and the original cost, change orders, revised Est, CTD, O/U and Percent Complete in the VALUES field.

Right Click within the Pivot Table to set the pivot table options to display as the “Classic Pivot Table Layout”.

Double Click on the VALUES column headings to reformat the cell values and rename the headings.

Page 6: Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated

Everything looks relatively nice with the exception of the total Percentage of completion for the jobs within the customer. The pivot table is actually adding up the values in this column, we want the percentage of completion equation to be applied to the total column.

Click a cell within the Pivot Table to enable the PivotTable Tools tab on the toolbar. (NOTE: If you are not in a cell within the Pivot Table, this tab does not appear)

From the PivotTable Tools / Options Tab, select Formulas: Calculated Field.

This will give you access to creating formulas within the Pivot Table.

Page 7: Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated

The calculation for % Complete = Cost To Date / Revised Estimate. You may write the calculation as you would in a cell formula within Excel, but you will use the FIELD reference names. To avoid confusion, or misspelling, simple double click the Field name in from the lower window to make it appear in the FORMULA field.

Rename the Calculated Field in this space

The Fields available for calculation are shown in the “Fields” window. If data does not exist within the pivot table, you cannot perform a calculation with it.

Page 8: Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated

When you click OK to save the calculated field, the column is added to the Pivot Table. Note the total percentage of completion. This value now shows a true total percentage for all jobs within the customer.

After a little formatting of the values column and removal of the original percentage of completion, the report is looking much better.

Page 9: Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated

Just about the time we are getting all proud, we scroll down and see some errors caused by division by 0.

Although this will not affect the overall calculation for the % complete within the customer, if it looks like an error, it probably is.

Since the equation is written as Cost To Date / Revised Estimated Cost, we can write an IF/THEN statement into the calculation to remove the #DIV/0 error.

We need to rewrite the formula to state if the Revised Estimate is 0, then return a 0, otherwise perform the calculation.

=if( 'Revised Est' =0,0,CTD /'Revised Est')

Access the Calculated Field Function in the same manner as you did when creating the formula.

Use the dropdown arrow to select the calculated field you wish to edit.

Page 10: Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated

Job Profitability / Cash Flow

Create a query using the job_history, jobs and customers tables.

Remove all table links other than the link between:

JOBS and CUSTOMERS = customer_no

JOB_HISTORY and JOBS = job_no

(You can always assume to remove the links on the row_unique_id fields between any and all tables.)

job_id Job Customer Cost10 10 - T&M Job 10 - T&M Client CUSTOMER REC 1,403,548.39$ 100 100 - Home / Away Job TEST - Test 382,585.47$ 1000 1000 - Strongsville Schools 1005 - Urban Contractors 2,654,949.57$ 10000 10000 - FESSLER & BOWMAN 110 - Hacker Owner Purchases 8,797.97$ 1001 1001 - Valley City Steel 1001 - ABC HighRise Development Co. 1,200,222.03$ 10010 10010 - Powell Job 107 - Document Control Customer 45,205.00$ 1002 1002 - Mentor Senior Center 1002 - Mateway Building Co. 305,954.03$ 1003 1003 - Perry Plant 1004 - Velon Construction 53,050.31$ 1004 1004 - Bagley Road Resurface 1002 - Mateway Building Co. 9,671.86$ 1005 1005 - OLD 1001 - ABC HighRise Development Co. 72,454.96$ 1006 1006 - Method 1 P/W BILL - Bill Test Cash Receipt 5,546.50$ 101 101 - Cleveland Mason KERRI - Kerri 3,600.00$ 102 102 - Akron Mason 1001 - ABC HighRise Development Co. 5,434.09$ 103 103 - PERDIEM JOB 200 - Comitted Cost Client 2,542.28$

Page 11: Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated

On a second worksheet, access the v_em_jc_billings table. This table contains all of the billings and payments by job.

Pull in the job_id (which will be used as our reference back to the Job History table) along with the sum of the AMOUNT_INVOICED and the sum of the CASH_AMOUNT.

We will write Sumif formulas to join the data from the first and second worksheets.

Page 12: Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated

We can create a pivot table off of the information on this report. All of the calculations will be performed as a function of the Pivot Table.

(Don’t forget to format the pivot table in the “Classic Style”!)

Create a calculated field inside the pivot table for Profit = Billings - Cost

Page 13: Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated

Also create a calculated field for Profit %. We have already created the field for Profit, so this can be used in the profit % calculation.

=(Profit/BILLING )

You may notice that there are some #DIV/0 errors showing up in the calculations. We can resolve these issues with an if/then statement.

=IF(BILLING =0,0,(Profit/BILLING))

Page 14: Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated

A simple Cash Flow calculation can be written as follows:

This report now offers an answer to the age old question, “why do my jobs show a profit, but we never seem to have any money???”

Page 15: Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated

If we remove the Customer from the PivotTable, we can get some interesting reports with the filter options.

In the job drilldown, select VALUE FILTERS, “TOP 10”

These filters may be changed as needed to reflect different types of reports. In this example I have selected to show Top 20 items based on the Profit % of the job.

Page 16: Creating and Using Formulas in Pivot Tables€¦ · Creating and Using Formulas in Pivot Tables . This session will cover creating Pivot Tables and look into the use of calculated