Multiple Calculated Columns with Filters within Single Pivot Table - excel

I am working to create a Pivot Table in Excel that has multiple calculated fields that take into account whether a condition is true, but cannot figure out how to create this within a single Pivot Table.
Behind the scenes, I have a set of data with a column that can have these values: A,B,C,D,F,L, or R.
I have another column that is a dollar value, and another for Quantity.
I am trying to calculate the price per unit when the Category is A,B, or C, but also calculate the price per unit when the Category is D.
I can create multiple Pivot Tables and tie them to the same slicer, but the issue is this: I need to display the spending in each of the two categories for each location, and when I create two separate Pivot Tables for this, locations that do not have spending in one of the categories are excluded (in this below case, location 2 has no spending in Category D, so it does not show up in the second Pivot Table).
Here is a portion of my data set. The whole data set is over 100,000 rows and will change over time, so I do need a solution for the long-term.
Location Category Volume Quantity
1 A $120.32 6000
3 A $30.08 1300
3 A $60.16 2600
1 B $39.91 1000
2 B $318.50 13000
2 C $196.00 8000
1 D $220.50 8100
3 D $171.50 6300
3 D $35.90 1000
3 D $53.85 1500
2 F $416.50 0
1 L $24.50 0
2 L $30.08 0
1 R $55.13 0
2 R $55.13 0
3 R $110.26 0
Thanks in advance for your help and let me know if I need to clarify anything!

Alright, a little more digging yielded the answer.
A slicer should be included that has all locations selected, then it should be tied to all Pivot Tables in use.
For all Pivot Tables, go to Field Settings, then click on the Layout and Print Tab. Check the box 'Show items with no data'.
Then go to Pivot Table Options and select the values you would like to display for blanks and errors.
I found the solution here.

Related

Keeping rows based on source rankings in excel?

I have a table that looks like this -
Source Rank
Value
1
A
2
A
3
A
2
B
3
B
1
C
2
C
3
C
I want to make only keep the rows for each value with best rank. So the table will look like this -
Source Rank
Value
1
A
2
B
1
C
It's almost impossible to find a better argument for the invention of the "Subtotals" feature, as you can see:
Oh, in case you don't get the same results immediately: don't forget to click the 2 button in the left margin :-)
Create a Pivot Table from the source data, and set:
Row Labels: Value
Values: Source Rank - and use the pulldown to set to Min
Admittedly this will have the columns the other way round from what you show as ideal result.

Excel Pivot Table: Different Subtotals for Different Value Fields

I have an excel pivot table with two summed field values. I need to subtotal the first one using sum and the second one using average. Here is the desired output:
Region
State
SumOfSales
SumOfUnitsSold
A
NY
100
5
A
NJ
200
3
A Subtotal
300
4
B
FL
250
4
B
GA
300
2
B Subtotal
550
3
So far the closest thing I've been able to find is a custom subtotal through the field settings for Region. But this adds two rows for subtotals. Any ideas?

How to create a count table of two variables in excel pivot

I am struggling with creating a count table of two variables at the same time. Ultimately, I would like to create a bar graph of the table.
Assuming I have two items for a sample of firms and I just want a summary table of the answer count.
Firm Item1 Item2
1 1 1
2 2 1
3 1 2
4 1 2
Based on this answer, I can easily create the summary table for Item 1 telling me that "1" appears three times for item 1 and two times in Item 2. But I cant easily create a Pivot table showing this jointly.
I'm not sure I understood correct, but is it COUNTIF() you need?
In D1 type:
=COUNTIF(B:B, "1")
that should give you result 3

Find the top n values in a range while keeping the sum of values in another range under x value

I'd like to accomplish the following task. There are three columns of data. Column A represents price, where the sum needs to be kept under $100,000. Column B represents a value. Column C represents a name tied to columns A & B.
Out of >100 rows of data, I need to find the highest 8 values in column B while keeping the sum of the prices in column A under $100,000. And then return the 8 names from column C.
Can this be accomplished?
EDIT:
I attempted the Solver solution w/ no luck. 200 rows looks to be the max w/ Solver, and that is what I'm using now. Here are the steps I've taken:
Create a column called rank RANK(B2,$B$2:$B$200) (used column D -- what is the purpose of this?)
Create a column called flag just put in zeroes (used column E)
Create 3 total cells total_price (=SUM(A2:A200)), total_value (=SUM(B2:B200)) and total_flag (=(E2:E200))
Use solver to minimize total_value (shouldn't this be maximize??)
Add constraints -Total_price<=100000 -Total_flag=8 -Flag cells are binary
Using Simplex LP, it simply changes the flags for the first 8 values. However, the total price for the first 8 values is >$100,000 ($140k). I've tried changing some options in the Solver Parameters as well as using different solving methods to no avail. I'd like to post an image of the parameter settings, but don't have enough "reputation".
EDIT #2:
The first 5 rows looks like this, price goes down to ~$6k at the bottom of the table.
Price Value Name Rank Flag
$22,538 42.81905675 Blow, Joe 1 0
$22,427 37.36240932 Doe, Jane 2 0
$17,158 34.12127693 Hall, Cliff 3 0
$16,625 33.97654031 Povich, John 4 0
$15,631 33.58212402 Cow, Holy 5 0
I'll give you the solver solution as a starting point. It involves the creation of some extra columns and total cells. Note solver is limited in the amount of cells it can handle but will work with 100 anyway.
Create a column called rank RANK(B2,$B$2:$B$100)
Create a column called flag just put in zeroes
Create 3 total cells total_price, total_value and total_flag
Use solver to minimize total_value
Add constraints
-Total_price<=100000
-Total_flag=8
-Flag cells are binary
This will flag the rows you want and you can grab the names however you want.

Sum elements in matrix in Excel

id a b c
1 0 0 0
1 0 0 0
2 0 0 0
2 0 0 0
3 1 2 3
3 0 0 1
Given the above matrix, I want to create a new matrix, which sums the numbers within the first matrix for a given id in a given year (a,b or c). So for the above, it should look like:
1 2 3
a 0 0 1
b 0 0 2
c 0 0 4
Can anyone see what to do?
Try using SUMPRODUCT rather than SUMIFS, e.g.
=SUMPRODUCT(B2:D7,(B1:D1="a")*(A2:A7=1))
The formula solution given in the other responses will work well when data headings are already in place and the data range is not too large.
A pivot table creates the row and column headings for you and will update as new data is added when you click the Refresh Button, it's also significantly quicker when the data range is large.
Steps
A) Choose Insert | Table for your data range, and give it a suitable name, the default is Table1
B) Access the PivotTable wizard via the shortcut Alt+D+P (this is not on the default menus).
1) Multiple Consolidation Ranges
2a) I will Create the Page Fields
2b) Range: Table1[#All] Page Fields: 0
2c) Existing Worksheet: $A$7
C) Click Finish, switch Row and column fields and turn off totals and autoformatting
I suggest that you try solving that problem with pivot tables.
Here are 2 links that you might use to learn that feature:
http://www.cpearson.com/excel/pivots.htm
http://www.youtube.com/watch?v=7zHLnUCtfUk
The only drawback with Pivots is that if the size of the source range changes, the Pivot will not adjust automatically. So once you managed to solve your initial problem and understand the power of Pivot Tables, I suggest that you use a Dynamic Named Range as the source of your Pivot.
Edit:
I feel that barry houdini's solution is simpler. I reproduced it below (with all credit belonging to him!)

Resources