formula to calculate variance on a single pivot table column - pivot

Is it possible when pivoting a series of data to calculate the difference between 2 columns when 1 column is your column filter? for example, I'm trying to compare 2 accounts receivable reports a week apart, so I inserted a manual column in both reports called "week" and then, before pivoting, I consolidated the 2 reports. Now I have 1 column called "week" with 2 different values. When I pivot, I want to put the "week" column in the Column Filter and I want to put the outstanding balance in values, and I then I need to calculate the difference between the weeks. I can't seem to find a way to do this.
Thanks,

Assuming you are using MS Excel ...
From your description, I believe you have a raw data table that looks like this ...
... and a PivotTable that looks like this ...
If you were looking to calculate the difference between Account1 and Account2 on a weekly basis, this would be straight forward, using a calculated field. However, in order to calculate the change in Account 1 week over week, and the change in Account 2 week over week, you will need to go back to the raw data table and perform the calculation there, in new columns.
In the raw data, Column A is Week, Column B is Account1, and Column C is Account2 ...
Make header in Column D Acc1WkChng and the header in Column E Acc2WkChng
The first row of each of these columns is 0. The second row of Acc1WkChng is =B3-B2. The second row of Acc2WkChng is =C3-C2
The raw data table now looks like this ...
On the PivotTable, pick the PivotTable Tools -> Analyze Ribbon. Choose Change Data Source and increase the selected range to include Columns D and E.
Add Acc1WkChng and Acc2WkChng to the Values area. Format accordingly.
The PivotTable now looks like this ...
Note: This pivot table is merely a transpose of the original data. Presumably, you want to do something more interesting with it.

Related

Excel: transpose rows to columns and merge

I would like to present some data in Excel in a table. I have a sheet with three columns: date, time_spent and user_id. Every row is a data record. I want a table with a column for every date and every value with time spent below the date.
Using the transpose function under paste special I get this:
However I would like only one column per unique date, so the amount of columns decrease like this:
Does someone know how to do this?\
I have more than 10000 rows, so manually is too much effort...
Using Pivot Tables as Tim Biegeleisen suggested I cannot get what I want either, I'm not an expierenced user of Pivot Tables so probably I'm doing something wrong:
Excel file as shown in above picture
Here is one way of using a Pivot Table as suggested by Tim above in the comments, but you must use it on your original, non-transposed data: (and note which parameters go to which areas.
A disadvantage of the Pivot table is that the column headers are text strings and not dates. If your version of Excel is 2010+, you can use Power Pivot or Get and Transform to do a better job:
Open the Query Editor, change the format of the Date column, and Pivot the column:
Then Save the results:
Advanced filter dates to unique values in a new column
Copy and transpose them to make your column titles
Insert a new column B with the formula =TEXT(A2,"yyyyddmmm")&COUNTIF($A$2:A2,A2) and fill down
Below your new column headers put in the formula =IFERROR(VLOOKUP(TEXT(H$1,"yyyyddmmm")&ROW()-1,$B$2:$C$8,2,FALSE),"") and fill down and across. You will need to fill it down to cover the maximum number of instances of each date.
Adding a sumif to this table and your initial table would be a good way to check you got everything.

Need light formula to get some counts in large data sheet

I have an employee data base that contains names and 8 movement types (Ex. Recruitment, Resignation....etc). Also I have starting head counts.
What I need to do is calculating movement counts and head counts based on the month for 12 months. Currently i am using SUMIF formula to calculate all these and the thing is excel will be very slow with all formulas. Appreciate if anyone can help me on this. See the image below for sample of the formula and I need to insert this formula in more than 600 lines.
A pivot table would be a good way to go, but by the look of your criteria you'll need to create 'helper columns' to ensure your data is ready for aggregation in a Pivot table.
For instance in your master data tab, add a new column called 'MatchesCriteria' or words to that effect, and build a formula in that column that checks for all of the criteria that you want to have the report based on, and returns a 1 or a 0, e.g.
=IF( (IF(C2="Recruitment",1,0)+IF(D2="Secondment In",1,0)) > 0 , 1 , 0)
Then run a pivot table including the 'Plant' column in your Rows, the month column in your columns and the 'MatchesCriteria' in your data values, and switch the calculation type to 'SUM' rather than 'COUNT'.
This will do the trick and will refresh in a flash compared to evaluating all of those countif statements.

Excel - Pivot Tables: Display Dates Not in Source Data

I am importing a report that has a strict template from a sales monitoring site and I need to create a pivot table to reflect the data. The report generates data on daily sales for the month. The issue: I want a pivot table to reflect the imported data, but display 0's for the dates that are in the future.
For example, my data is being imported and has data from 3/1/16 to 3/21/16 (today's date). I want a pivot table generated from this data to display the full month of March, with 0's for the dates after today. Is this possible?
As far as I know, pivot tables need a data source to read from. So if you want the rest of month to show up with 0's, you will need to create dummy data for it. So fill out the data source with the rest of the month and 0's in all the columns. Then it will show up in your pivot table (as long as those cells are part of the pivot table's data source).
Without seeing the full layout you have in mind, it's difficult to be precise with an answer. Based upon what I can gather from your original post, I'd recommend inserting a column into your source data, let's call that column B.
Let's say your source data dates are in column A. Let's assume you have a header row in row 1 and column A is formatted as Date.
Insert a formula into B such that:
=IF($A2>NOW(), 0, $A2)
This will give you a column that either returns zero for future dates or the source data date for dates in the past/present.
Update your pivot to reflect the new column B instead of Column A. The challenge you will have is that Excel will attempt to present 0 as a date (since the rest of the column is a date), showing 01/00/1900 instead of zero.

Complicated Formula Issue adding specific values based on a parameter

I have a table A and table B. Table A is the input table and table B is the output table. Table A has 2 Columns; Name and Quantity, and table B also has 2 Columns Name and Quantity, but the difference is that table B already has 48 names written inside it and the Quantity section is empty, And the whole of table A is empty. I'm not doing a very good job of explaining stuff. I know but if you are with me so far then.
Now I go to table 1 and put in the following data in the syntax [Name,Quantity] : {Sam,10},{Lilly,15},{Sam,25}. After putting in that data, I want the appropriate quantity cell in table B corresponding to the names to be equal to the total quantity each name has in table B.
In this case I want the output of table B show me {Sam,35},{Lilly,15} and the rest of the Names = 0.
I would prefer if this method stays in the terms of excel formula calculations and no macros or VBA as it will be easier for me to integrate this with the other functions of the spreadsheet I'm making. But I would not mind having alternatives.
If your data format is like this:
You could use either SUMIF or a Pivot Table
If you use SUMIF, then you could list all the names with zero's.
If you use a Pivot Table, a list of names will be generated automatically.
For SUMIF, if the Quantity column of Table B starts in B2, you could use a formula like:
=SUMIF(Table_A[Name],A2,Table_A[Quantity])
and fill down to last row.
If Table A is not a "real" table, just substitute the range references for the appropriate columns.
Results of the SUMIF method:
If you want to use a Pivot Table, then with the cursor in Table A, select Insert / Pivot table. Then drag Name to the Row Labels area, and Quantity to the Values area. Format to taste.

Summarise data based on date

I have a set of data in excel that looks like this:
Project Name alpha date alpha price beta date beta price final date final price
Project a 1/01/2013 $123.00 2/02/2013 $324.00 5/02/2013 $222.00
Project b 2/01/2013 $432.00 9/03/2013 $111.00 30/03/2013 $321.00
project c 2/02/2013 $4,431.00 8/03/2013 $231.00 7/04/2013 $343.00
project d 3/04/2013 $1,232.00 30/01/1906 $3,122.00 6/07/2013 $666.00
I need to generate a sum for each month/year across all projects and phases of the project. IE:
Jan 2013 $555
Feb 2013 $4,977
What's the best way of going about this?
This is a good use case for pivot tables.
Highlight the date columns, right click, Format Cells.. menu item. Then use a Custom Data format of MM/YY to get everything in month and year format.
Once all the dates are converted, highlight the entire table then make a Pivot Table of the data (use Create Menu). Place pivot table on new sheet.
Use the pivot table to group and sum data as needed. You can drag the various projects into pivot table rows, and then combine cost columns using the sum() function. Add filters or project groups where needed.
If you've never used pivot tables, I highly recommend taking 30 minutes to learn. They are very intuitive and powerful.
Good luck!
A suggestion is to ‘reverse pivot’ (eg as described An excel formula to find a row/column index in array) and double click on the intersect of the Grand Totals. Insert a column with:
=MONTH(Table1[[#This Row],[Value]])&" | "&YEAR(Table1[[#This Row],[Value]])
and a column with, in the first row below the headers (assumed to be Row1): =C3 where C is assumed to be the Value column.
Copy the Table and Paste Special Values.
Filter the Column column and delete all rows containing price.
Sort the month/year column and Subtotal, for each change in that column, the other added column.

Resources