Excel 2010 Pivot Table issue - excel

I have the below pivot table
Category Total Count(calculated value) # Completed Count(calculated value)
Red 38,357 18822
Blue 182 155
Green 7,153 4,761
I would not like to calculate a % of the two counts. So show the % of 18,822/38,357, etc. How would I go about getting this metric?

Insert a calculated Field. In the formula box divide by the true column name. So for instance if it's a calcululated value Count of "xx" exlcude the count of and use only the column name.

Related

Pandas Pivot table prevent filling empty values with 0

I have a pandas DF column (Coded Sentiment (NUM)) that has numerical values, but not all column rows contain a value. See bottom half of the DF some rows are blank.
ContentID Coded Sentiment (NUM)
0 48a799ca7254c59f56daa3aa429f0e250ba294656ab1a6... 0
1 13674042c5f8e452abaddeec1d1509525f4a3cdfb9f3fb...
2 43f821e7431e024ee6b3fe2403847a888f148ffb737f42... -1
3 7f9e89d6c2b5b705ff3d1667410f6d21730424e5d79c52... 0
4 7f9e89d6c2b5b705ff3d1667410f6d21730424e5d79c52... 1
.. ... ...
313 58e18ae5a381450c6f24c5f72c2c71f49e795723d1310f... 1
314 19fd002ffbaab001a0aa2e8c2373aa5a932b6a40510830...
320 b3846c295d5cfe430a8c3faf4078ae7bccb50f1ec7e35e...
321 b3846c295d5cfe430a8c3faf4078ae7bccb50f1ec7e35e...
322 475bae274bcad23ce3947e4c910b20cfae4aad9aea24a8... 1
I need to create a pivot table to sum the numbers for each unique content ID
program_data_sheet_sentiment_fix = program_data_sheet.pivot_table(index='ContentID', values='Coded Sentiment (NUM)', aggfunc= np.sum)
Here is where my problem arises, when I create the pivot table, any rows that don't have any number in the sentiment column returns a 0 in the pivot table for that specific content ID.
What I need is for the pivot table to not add the 0 to any blank values. I need to keep the value blank if there are no numerical values associated to that content ID. This is because blank values and the value 0 both mean something different in my data process so it's important to not add 0 for blank values.
So ideally when I create the pivot table, the content ID found at row index 320 & 321 the sum would simply return a blank value since there is nothing in the sentiment column.
Hope this makes sense.
Can someone point me in the right direction?

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 group multiple cells with the same values in Excel

I am trying to group multiple cells in Excel to give me an end value of the total of times those three cells exist, for example, if the Country is "UK", the Method is "Method1" and Weight is "400", instead of that appearing 2 times as it does in the table below, I would like to merge it so it is there only once, but the Amount column has a value of "2" to represent how many times it is in the Sheet. The data I am using has thousands of different and varying values. I am using Microsoft Excel 2016.
Thank you.
Current Sheet:
Country Method Weight Amount
USA Method7 200 x
UK Method1 400 x
UK Method1 400 x
FRANCE Method55 3994 x
Desired Sheet:
Country Method Weight Amount
USA Method7 200 1
UK Method1 400 2
FRANCE Method55 3994 1
This is how my original data looks like:
And I can resume it as you need using Pivot Tables
Make sure you set the Pivot Table Value Property as count when
using the field Amount
Just in case it may help, I'm attaching how I set up this Pivot Table to make the operations you need (please, note my Excel is in Spanish, but position of each field must be the same, and the operation in Values section affecting field Amount must be COUNT)
As there is a direct link between country, method and weight, you can use subtotals for that (menu "Data", chapter "Outline", feature "Subtotals"). You configure it as:
At each change in : "Country"
Use function : "Count"
Add subtotal to:
Country (No)
Method (No)
Weigth (No)
Amount (Yes)
Replace current subtotals (Yes)
Page break between groups (No)
Summary below data (Yes)
Your result will look as follows:
By clicking on the numbers 1, 2 or 3 in the left margin, you'll be able to view/hide subtotals for that country.

Excel: how to NOT sum based on text values?

I am trying to sum values based on another text column.
Let's say my data look like this:
date item amount
4/3/03 book 100
8/3/05 rent 1090
5/6/06 food 5
2/7/09 repair 390
8/3/10 rent 1090
so I want to sum all the spendings (amount) when the "item" section is NOT equal to "rent", but I dont just want a grand sum, I just want a sum that's up to that date.
So the desired output (last column, subtotal) should look something like this:
date item amount subtotal
4/3/03 book 100 100
8/3/05 rent 1090 100
5/6/06 food 5 105
2/7/09 repair 390 495
8/3/10 rent 1090 495
I've tried to sum it up while filtering the rolls to only show anything but rent, but when I clear the filter, all the numbers will sum INCLUDING rent.
I've also tried using SUMIF (I named the top cell in "Amount" column as "first_amount"):
=SUMIF(C2,"rent",first_amount:E2)
But I dont think I'm using it correctly or maybe it just doesn't work. It shows no value whatsoever.
I found this post and read through the function pages, but still am not being able to do what I wanted to do:
Excel summing values based on multiple conditions
BONUS:
What if I want to exclude both "rent" and "food"?
I'm sure there's a very simple solution out there that I am just too dumb to think of. Any hint/help is truly appreciated!
Assuming A1 is the first cell make D1:
=SUMIF($B$2:B2, "<>rent", $C$2:C2)

Graph grouping by and percentages

I want to create a chart in Excel but I don't know how is it possible having the table below:
ID | MODEL
==========
1 LG-1
2 HP-2
3 HP-2
4 HP-2
5 LG-1
6 GE
7 HP-1
8 HP-1
9 HP-2
10 HP-2
The result I need is a graph showing the percentage of each model in the table
e.g. in any chart:
LG-1 = 20 %
GE = 10 %
HP-1 = 20 %
HP-2 = 50 %
Somewhere the relative counts of groups (i.e. their percentage shares) need to be calculated so I suggest for Excel 2013 selecting your data range (including labels) and clicking on INSERT > Charts - PivotChart (the down arrow) and PivotChart then select Existing Worksheet entering a suitable Location: and OK. In PivotChart Fields, drag ID to VALUES and MODEL to AXES. Click on the arrow next to Sum of ID, change to Count of ID and click on Value Field Settings..., on Show Values As and select Show values as "% of Grand Total", OK.
This way I end up with:

Resources