Excel Pivot table subtotal with element exclusion - excel

I want to add the extra line of Grand Total of the pivot table,
which excludes some element group. Is it possible to do this?
For example, I want to add subtotal of [East excluded New York Total],
is it possible without adding the additional column for grouping purpose from the source data/worksheet?
Because I further want [East + West Total]
and [East excluded New York + West Total]. The approach of adding extra group label columns is not flexible enough as the group subset is not static (i.e., New York sometimes is a subset of East, sometimes not,
for showing subtotal). Thanks.
eg.
East
New York 100
Boston 200
Philadelphia 300
[East excluded New York Total] 500
East Total 600
West
XXX 999
YYY 999
XXX 999
West Total 999
---------------
[East excluded New York + West Total] 999
GrandTotal 9999

Presuming the cities are in Column A and start with A2 and ends wit A5, then resulting cell will be:
=SUMIF(A2:A5, <>"New York", B2:B5)
will do the trick.
Though to be noted, pivot tables were never intended to yield extra rows and it may actively hurt your table structure.
Easiest solution to not get interfering dynamic ranges would be to treat East Coast and Web Coast as seperate Pivot Field Columns instead of Field Rows.
This way, you can apply the formula to entire [#Column]

Related

I need to find a way to show the number of relationships between values in two different excel columns

OK, I have two columns in excel that contain city names. I need a rank of how many times a relationship between two cities occurs. For example, the ranking for the data below should be as follows. #1 is Austin to Dallas with 3 occurrences. #2 is Chicago to Boston with 2 occurrences. #3 is Chicago to New York with 1 occurrence.
sample data set
You can use a =COUNTIFS statement to check specific cities.
For example:
Row 1 = Headers
Column A = Origin City
Column B = Destination City
Data in your table should be in A2:B7
You can use:
=COUNTIFS($A$2:$A$7,"Austin",$B$2:$B$7,"Dallas")
=COUNTIFS($A$2:$A$7,"Chicago",$B$2:$B$7,"Boston")
=COUNTIFS($A$2:$A$7,"Chicago",$B$2:$B$7,"New York")

Excel Vlookup Multiple Values

I am looking for a vlookup formula that returns multiple matches using two lookup values. I am currently trying to use the concatenate method, but I haven't quite figured it out. The table needs to return all of the multiple matches not just one. Currently, its only returning the last match.
For example, lets say I have a list of multiple city and states. The cities differ but the states remain the same obviously. I want to return the number of people in the each city.
City State #OfPeople
Albany NY 10
Orlando FL 5
Tampa FL 3
Seattle WA 1
Queens NY 8
So I concatenated the city and state column.
Join City State #OfPeople
Albany-NY Albany NY 10
Orlando-FL Orlando FL 5
Tampa-FL Tampa FL 3
Seattle-WA Seattle WA 1
Queens-NY Queens NY 8
The purpose of this is to create an updated log of people in each city has time progresses. I want to have a grand total amount of people in each column. (I know this requires another formula. I'm just focused on returning multiple matches for now). However, I don't want to overwrite the existing data. Hopefully, I explained this well. This is just an example of a larger project I'm working on. I need to be able to build on this list. That's why its important that I be able to return matches multiple times.
Join City State #OfPeople Total
Albany-NY Albany NY 10 10
Orlando-FL Orlando FL 5 15
Tampa-FL Tampa FL 3 18
Seattle-WA Seattle WA 1 19
Queens-NY Queens NY 8 27
Any help would be greatly appreciated!
Considering you're trying to get some grand totals based on multiple criteria, I would suggest using SUMIFS() / COUNTIFS() functions, rather than focusing on searching matching row itself.
However, if you need multiple criteria look up, for some reason, I believe INDEX() + MATCH() combination can perfectly do the job.
The table needs to return all of the multiple matches not just one.
Currently, its only returning the last match
You'll need to use SUMIFS() if there are multiple records for the same city/state combo in your people lookup.
=SUMIFS (sum_range, range1, criteria1, [range2], [criteria2], ...)
Let's assume that you have a cities tab and a people tab. Let's assume you have ten cities that you want to return the total amount of people from.
Cities Tab definition
City range: 'Cities'!A$1:A$10
State range: 'Cities'!B$1:B$10
People Tab definition
City range: 'People'!A$1:A$100
State range: 'People'!B$1:B$100
#OfPeople range: 'People'!C$1:C$100
Drop this formula in the first row of your cities tab, drag down the entire range of cities.
=SUMIFS('People'!C$1:C$100, 'Cities'!A$1, People'!A$1:A$100, 'Cities'!B$1, 'People'!B$1:B$100)

Lookup and replace specific values with reference in pivot table

If I'm trying to find specific names in a list given from my pivot table such as -
Row Labels Revenues Order #
Panera 25 0
Pasta 15
Salad 10
Olive Garden 40 0
Sandwich 20
Pasta 20
Panda Express 30 0
Rice 15
Chicken 15
And I want to search through my document, find Olive Garden and Panda Express and I wanted to replace the 0 in the order # column with 10 for Olive Garden and 20 for Panda Express. Currently, someone here helped me out with
=IF(IFERROR(VLOOKUP(A9,worksheet!K:K,1,FALSE),"")="","",0)
which inserts 0's for the headers and blanks for the orders in the 'Order #' column, can I add a second formula that would find the names and replace the value in that column? Or adjust the current formula?
Quick note - order # column is not from the pivot table.
To make it more clear, - I am getting data from an external source (i.e. paper invoices), as opposed to making a manual entry to adjust the 0's in the order # column, I would like to tell VBA/Excel - "hey Olive Garden's order number is 10 and Panda Express's order number changed to 20, adjust".
this is my end goal -
Row Labels Revenues Order #
Panera 25 0
Pasta 15
Salad 10
Olive Garden 40 10
Sandwich 20
Pasta 20
Panda Express 30 20
Rice 15
Chicken 15
If you have a range with the restaurant names in one column and the order numbers in the next column (say columns X and Y of the sheet called "worksheet"), you could change your formula to be
=IF(IFERROR(MATCH(A9,worksheet!K:K,0),"")="","",IFERROR(VLOO‌​KUP(A9,worksheet!X:Y‌​,2,FALSE),0))
(P.S. Changed the original VLOOKUP to MATCH based on useful feedback from teylyn.)
FWIW, that formula would be better using MATCH, not VLookup, since it's returning the value from the first column.
But back on track: what are you trying to achieve? Change the values in a pivot table?
First, a formula cannot change values in another cell.
Second, a pivot table reports on existing data. You can't change the numbers that a pivot table reports.
You will need to re-think your approach. If you don't like the numbers the pivot table returns, you'll need to change the underlying source data.

Adding a Column with Condition on Pivot Table

Been trying to figure this out for a while -
If I have a situation in which my pivot table gives me something along the lines of:
Row Labels Revenues
Panera 25
Pasta 15
Salad 10
Olive Garden 40
Sandwich 20
Pasta 20
and I wanted to insert a column next to revenues with 0's only for the rows with headers (panera, olive garden) and leave the rest of the rows for the orders blank - i.e.
Row Labels Revenues Order #
Panera 25 0
Pasta 15
Salad 10
Olive Garden 40 0
Sandwich 20
Pasta 20
is there a way to do this either in VBA, or just with a formula? Within my pivot table, the headers are labeled "restaurant name" while the subsets are labeled "orders", I was thinking about saying something along the lines of - if it's a restaurant name, insert 0, otherwise leave blank - but not sure how to do that or if there's an easier way?
If there is no overlap of names of restaurants and names of orders (i.e. you don't have a restaurant called "Pasta" for instance), you could use a formula such as
=IF(IFERROR(VLOOKUP(A3,'Sheet2'!A:A,1,FALSE),"")="","",0)
(assuming your pivot table was extracting the original data containing the restaurant name from column A of Sheet2)

Excel Charts for table with many duplicates

I have a list of names with 1000 entries and maybe 750 unique. There are other attributes, like location and position. Can I create a pivot table that would show me simple stat's like X number of unique people, X number unique in location 1, location 2, location 3, and finally x number of positions in location 1, position 2/location1, position 3/location2...?
Name Location Title
Smith, Bob UK Sales Manager
Smith, Bob UK Plant Manger
Jones, Keith UK Sales Manager
Jones, Keith UK Plant Foreman
White, Derick Denver Sales Manager
Brown, Frank Boston Supply Chain
Black, Jay Denver Sales Manager
Smith, Jeff Denver Sales Manager
Gonzalez, Al UK
Gonzalez, Al UK Staging Area Manager
Bright, Susan Denver Legel Secretary
Bright, Susan Denver Paralegal
Bright, Susan Denver Executive Assistant
Bright, Susan Denver Press Secretary
Alf, Jeff Denver VP, Sales
Green, Burt Boston VP, Sales
Jones, Chuck Denver Plant Foreman
Alten, Cory Denver Sales Manager
Clark, Jerry Boston Plant Foreman
Romo, Tom Denver Sales Manager
You may want to consider using CountifS functions in adjacent columns to the data. For example to count unique people, just create a column (call it column x for this example) and enter =Countif(Column A, A1) and copy down for all the rows. then just enter =countif(Column X, 1) and that should give you the unique names.
You can use CountifS function for more complicated counting logic to answer the other questions.
I have done similar counting of unique entries using pivot tables.
I create a additional column that has a 1 if it is the first occurance of the "key" (ie name). The formula is similar to this: (assume Column A has the "key")
=IF(ROW(A1) = MATCH(A1,A:A,0),1,0)
This formula is then copied down for every row (or if it's a proper table, it's auto copied!)
The idea is that the MATCH returns the row number of the first occurrence of "key". If it is the same as the current row, then count 1. If the values aren't the same, it's a duplicate, so give it a 0 value.
When you then do a pivot table sum on this value, it adds up to the number of unique entries. (ie unique names in a region.)

Resources