creating a calculated field in excel pivot table based on an item in a column - excel

Normally calculated pivot table fields in excel (2010) you click:
design tab > options and sets > calculated field
and if you had three columns: name, sales, cost
name | sales | cost
josh 10 2
your calculated field might be: profit which would be: = sales - cost.
However is it possible to make a calculated field which calculates the difference between two items in the one "Week Ending" column?
For example "Week ending" contains a dates which end on a friday 2015-05-01,2015-05-08,2015-05-15 etc and they are in the column labels section of the pivot table.
The "week ending" dates are all in the one column, is it still possible to calculate the difference between two of them with a calculated field?
name | End Fri 2015-05-01 | End Fri 2015-05-08 | calculated (Delta)
josh 8 10 10-8 = 2

You do this with a Calculated Item. Here is an example that I think gets close to what you want. I selected one of the dates in order to get the menu to show up.
Here is the result
And here is a good reference about these. http://www.contextures.com/excelpivottablecalculateditem.htm

Related

How to align offices in excel based on the number of months it has been open?

The data I have has multiple offices (600+) with different opening dates as the years have gone on. However, we frequently need to do analysis where we line up everything based on how long it has been open. For example, what is the average revenue performance of an office in it's first 6 months of opening. We have manually been lining up every office so that each month 1 is together, but there has to be an easier way?
Data example:
Offices & Open Dates:
Office X- 03/07/2012
Office Y- 5/19/2014
Office Z- 12/01/2009
I need the revenue to line up as follows
Column A
Office X
Office Y
Office Z
Column B - Month 1 Revenue
Revenue for 03/2012
Revenue for 05/2014
Revenue for 12/2009
Column C - Month 2 Revenue
Revenue for 04/2012
Revenue for 06/2014
Revenue for 01/2010
Column D - Month 3 Revenue
Revenue for 05/2012
Revenue for 07/2014
Revenue for 02/2010
etc.
Any ideas on how to do this?
Thank you.
My comment mentioned using index and small in an array formula to extract the data if the revenue data is sorted by date. Array formulas can be tricky and having to keep the data sorted is a pain so I've had another idea.
If you are able to add a new column in your revenue data, preferably before the revenue value, then you can create an id that can be used with a simple vlookup to extract the data you need.
Let's assume that your office name is in column A, your revenue date is in column C and revenue value is in column D
You can use the formula below to create a unique id for each revenue month
=A1 & " MONTH " & countifs($A$1:$A$20,A1,$C$1:$C$20,"<="&C1)
=A1 gets the office name to use in the id and then we add the text " MONTH " to the office name.
The countifs part counts all the revenue dates with the same office name that are the same or older (so it counts itself and returns 1 for the oldest then 2 for the second oldest etc.)
We end up with an id column something like this
Office Name 1 MONTH 1
Office Name 2 MONTH 1
Office Name 1 MONTH 2
As you have 600 offices it could be a little bit slow so you could copy and paste as values once the formula has done it's work.
Now that you have this id column you can use it to extract the revenue data by month using a vlookup and if you have a list of offices and headings MONTH 1, MONTH 2, MONTH 3 along the top then you can automate the creation of the vlookup required to extract the data you need.
So if the office names are in column F and the headings start in column G the formula below can be autofilled across and down to extract the required values. Notice that the $F column for the names has the column locked and the heading value in G$1 has the row locked because the $F2 & G$1 create the id "Office 1 MONTH 1"
=iferror(vlookup($F2 & G$1,$B$1:$D$20,3,false),"")

Excel: Index match if date matches month?

I have two excel sheets:
Data:
Column A Column E
01/01/2017 Supplier 1
05/01/2017 Supplier 2
05/01/2017 Supplier 1
Sheet 2:
I am trying to look up the supplier where the month of the date in column A matches the month number in cell F11.
F11 = 1
=IF(ISERROR(INDEX(Data!$A:$I,SMALL(IF(MONTH(Data!A:A)=$F$11,ROW(Data!$A:$A)),ROW(1:1)),5)),"",INDEX(Data!$A:$I,SMALL(IF(MONTH(Data!A:A)=$F$11,ROW(Data!$A:$A)),ROW(1:1)),5))
For some reason this doesn't work and i get no result.
I also need to only list each supplier name the once, unique values. But i believe my formula gives me the same result twice.
Please can someone show me where i am going wrong?
Can't you do this with a pivot table?
Just drag the date field into the columns box, then right-click, choose 'Group' and choose 'months'. Then drag the supplier field underneath it and you should get a list of all unique suppliers by month.
Edit:
Example below.

calculating proportion of sales in powerpivot

I have a powerpivot table that looks like this:
Product, Units_sold, Year
A 10 1990
A 5 1990
B 12 1900
C 50 1900
I want to create a calculated field for the contribution to overall sales of each sale, e.g. in this case divide every number by 77.
How can I do that in Powerpivot?
Use this formula for your calculated column:
=[Units_Sold]/SUM([Units_sold])
Rename your column and choose formatting from the Home menu.

Sorting multiple columns based on product name in Excel

I have a question about sorting multiple columns based on name. I know this is a job for vlookup or index match based on my Google results, but I am having trouble creating my solution. I am creating a worksheet that will have two columns for everyday of the month.
So the column names across will be: Product, Sales, BLANK, Product, Sales, etc) Some of the columns have more products and I want all the columns to have the same order.
So for example if the prduct was it Column A, but not column D, there would be a blank row in D to indicate this.
Can someone walk me through creating this formula?
If you have an option of keeping the data in table format (example below), then Pivot table will be an easy solution.
Data (wouldn't have bullets but I couldn't format it differently here):
Date Product Sales
Jan 1 prod1 $1,235.00
Jan 1 prod2 $5,104.00
Jan 1 prod3 $21.00
Jan 2 prod1 $254.00
Select all your data, then in the Menu bar click on Insert -> Pivot Table -> Ok. Choose date for your Column Headers, Product for your Row Headers and Sales for Values. Hope this helps!

Issue with Excel Pivot Table Subtotals / Row Hierarchy

I currently have a pivot table with three row labels. The data in the row labels is grouped as follows:
Customer SKU Grouping YTD PrevYTD
123 ABC Qty 30 20
Sales 500 400
DEG Qty 100 150
Sales 1,000 2,000
The YTD and PrevYTD are columns and the values.
I can do a custom subtotal on the 'Grouping' field and choose Sum and it gives me the totals at the end of the report:
Qty Sum 130 170
Sales Sum 1,500 2.400
This is good to this point, but I also want to have subtotals by customer. What I want to see is the same breakdown under each customer (a total of Qty and a total of Sales) but I cannot get this subtotal to work. When I put a subtotal on the Customer field, it puts a oneline subtotal and is adding the Qty and the Sales together. In this example if I put a subtotal on Customer This is what it will display:
123 Total 1630 2570
Is this possible to do what I am looking for?
Thanks for the help!
How about making Grouping a column label instead? It will change the layout somewhat but will allow you to get the effect you are after.
To do this you need to use a second pivot table. It's easier to do it with the tables side-by-side, but you can do it with a table underneath by just deleting the second table and inserting a new pivot table after the last row of the first each time the first table is changed.

Resources