Pivot table value display - excel

I'm trying to change the way a pivot table displays values that im trying to track on a month to month basis. Below is a picture of what I have vs what I would like:
The first table is what I have. The second table is one I manually created to show what I would like displayed. Basically what I want to display is the % of total in column P for all of the highlighted cells in column F through O. I cant figure this one out after a good bit of trial and error and googling. Any help would be greatly appreciated.
Here is an additional picture to add clarity to what I'm trying to display:

It is not clear what the percentages relate to in your screenshot.
In a pivot table you can set the values to display as percentages, with a few different options, like percentage of total, percentage of column, percentage of row, etc.
This Microsoft Support article has the details how to set it up.

Related

Insert subtotal for Excel spreadsheets

I have some irregular data (e.g. I have 5 groups of data, each group occupies different amount of rows) and I am wondering if there is a way to use Python to add subtotal to all of my spreadsheets, breaking at each group change.
Since row amount is irregular for each group, I tried inserting empty row at each change and adding a subtotal. However, I am unable to do a sum for each change or a grand total without using hard code (specify on the row number, which changes for every spreadsheet).
Thanks in advance.
Edit: Added code I am working on
for num in range (8, ws.max_row+1):
if ws['E'+str(num)].value == ws['L1'].value:
ws['L'+str(num)]='=SUMIF($A$'+str(ws[num])+':$A$'+str(ws[ws.max_row])+',LEFT(A'+str(ws[num])+',6),$E$'+str(ws[num])+':$E$'+str(ws[ws.max_row])+')'
num+=1
Can you add a column to each list that can help you categorize them? that way you can do a =SUMIF based on the categorized names. here's a code snipit and an image to reference:
=SUMIF(B:B,B15,C:C)
the formula calculates the left table (dogs).
as you can see the totals wont be added if the category is mentioned. also, all three tables are irregular so it will add up regardless of length.

Calculate average of values in a column based on matches of two variables in two other columns

I'm having an issue with some data that I'm working on that has had me stuck for a while.
I'm working on some patient data for a clinical practice that has each patient encounter logged on a separate line with an account ID, date of service, the height and weight measurements for that date, and other variables.
Aside from VLOOKUP and the usual formulae/functions I've got a pretty rudimentary understanding of Excel but I can pick up on things fairly quickly.
In the data I've got each line tied to a patient account ID as well as what quarter the DOS was in. For patients with multiple visits, they will be identifiable by repetitions of the account ID number on other lines.
For some patients, there will also be repetitions in the quarter if the same patient was seen twice in the same quarter. This is where I need help.
I'd simply like to average the value of a variable for each patient in each quarter. I'm not sure if AVERAGEIFS is the right function to use but I need an operation that checks for matches in a line of both account ID and quarter (Q1, Q2, Q3, or Q4) with the other lines in the sheet and comes up with a quarterly average for the variables in question.
What I have
What I need
If I'm understanding your question, you could use AVERAGEIFS to accomplish what you are asking. With excel, a lot of how successful an approach will be is determined by how your data is structured, and if/how often you are planning on updating your work.
It would be easier to give a concrete answer with an example of the data you are looking at.
If your source data is in columns A:D something like:
and you are looking to summarize the weight data in I by account ID and Quarter:
you could use AVERAGEIFS(C:C,A:A,G2,B:B,H2) this would find the cells in column A that match the value in G2, find the cells in column B that match the value in H2, and report the mean value in column C of the matching rows.
An alternative is to use a pivot table, which automates a lot of what you are trying to do. For that approach you would select your data block, and click on Insert>>Insert Pivot Table (at least in my version). That should bring up a wizard. Accepting the defaults will create a new sheet. Then look on the right side of your window, and you should see a list of your column names near the top, and four boxes called Filters, Columns, Rows, and Values. You should be able to drag and drop your columns into these boxes to get summaries of your data. If you add your Account ID and Quarter tabs as columns, and your height and weight as Values, then right click on each of the value columns and select "Value Field Settings" and select Average from the menu that pops up. That should give you something that looks like:
At that point, you can change the formatting to make if fit your needs, or copy data somewhere else.
The AVERAGEIFS approach will automatically update if you add more data, but will only summarize things that match the values you list. If there is an account ID/Quarter pair that isn't in the summary column you won't have any idea it's there. If you are summarizing an ID/Quarter pair that isn't in your data you'll end up with a division by Zero error like in the example.
The Pivot Table option only updates when you manually click refresh (right click and choose refresh pivot table from the menu), but will summarize all the data based on the columns you've selected. It's also a little more robust as you avoid having to type out the formulas and make sure you are pointing to the right column. This option also by default provides nested summaries; you can turn the subtotals and grand totals off if you want.
I used the function:
=SUMPRODUCT(($B$2:$B$13="Customer 1")*($C$2:$C$13="Q1"))
Where Customer 1 could be a user id and Q1 you can change to which quarter you want.
Excel screenshot

SubTotal - unable to get the correct value for the fields where avg out the vlaue

I need your help on the below two points:
1) When I subtotal the value based on the allocation key, the fields where i have used avg() to sum up the percentage is not summing up correctly.
2) How can i provide the different color coding for the sub total row and the header in the report.
Please refer the snippet for your easy reference.
Thanks in advance
enter image description here
Coding:-
Avg(If([Qtr]="Q1",[percentage])) as [Q1 %],
Sum(If([Qtr]="Q1",[Total Value $])) as [Q1],
Avg(If([Qtr]="Q2",[percentage])) as [Q2 %],
Sum(If([Qtr]="Q2",[Total Value $])) as [Q2],
There has been an update since 7.11 to allow the user to toggle between calculating values on the underlying data or whats shown in the cell values of the pivot table.
It is now possible to configure the cross table to calculate subtotals
and grand totals based on the aggregated values visualized in the
table, as an option to calculating it using the underlying row level
data. This is useful, for example, when you want to visualize the sum
of the absolute values of the categories displayed in the table:
As far as I know, you cannot do color customization to the Sub or Grand Total rows. You can edit the appearance of the Header row by View > Visual Theme > Edit Custom Theme and modifying the Details Tab. You can also pull in a template from one of the Spotfire Sample Reports that already do it if you want.
https://community.tibco.com/wiki/whats-new-tibco-spotfire?
The 6.5.3 User's Guide says this regarding the first question:
Note: The aggregated value for subtotals is not calculated on the
values shown in the cross table, but on the underlying row values. For
example, if "Average" is used as aggregation measure, the subtotal
average of a column is calculated on the rows the column is based on
and not on the values shown in the cross table.
I believe that "subtotal average" means the average of the rows involved in the calculation. I don't see any way to customize the way that subtotals are calculated.
For your second question, I don't believe that there's a way to do that, unfortunately.

How to generate a column in pivot table

I have a small challenge in excel.
Let's say I have a column called impressions and other column called cliks. I want to display the click rate on a pivot table (click rate is the ratio between clicks and impressions).
I tried (almost) everything, and unfortunately I am not being able to do it :(
As you can see from the image, I can manually calculate the click rate, however I am failing in do it inside the pivot table...
and this is how a calculated field is generated. Thank you JosieP, for your helpful comment.

Excel pivot table exclude some column totals

I am using an Excel 2010 pivot table to display data. I need the sub totals in most columns but some columns display percentages and totaling the percentages is not correct and displays confusing values. Is there any way I can choose which columns not to total.
It's hard to make sure I'm accurately addressing your question without more detail about your data, but I will provide a simple example.
Recommendation
I would suggest that you put all measures/values in the Values area of the Pivot Table, and not in the Row Labels. That way, you will not get Row sub-totals for values.
In order to address the non-additive totals and sub-totals for your percentages, I recommend that you remove the pre-calculated percentages from your Pivot Table Values and instead use a Calculated Field that is calculated within the Pivot Table itself from the base data, and will provide correct aggregate totals and sub-totals.
Example
See below:
Method
In order to create a Calculated Field using the Ribbon, select your Pivot Table, and then go to PivotTable Tools --> Options --> Fields, Items, & Sets --> Calculated Field.
Then, enter a name for the new Field (CalcPercentSoldUnits in my example below), as well as the formula definition for the field ( =UnitsSold /UnitsProduced in my example below). Click 'Add' to create the field and then 'OK' to exit the dialog box.
Now you have created a derived field not in your base data table, but in your Pivot Table, which can be used just like a normal field. You can also see that it will calculate totals and sub-totals correctly because instead of adding constants, it is calculating based on the sums of other constants from which the percentages are derived.
In some cases depending on how your data is structured, you may need to create a Calculated Item instead of a Calculated Field.
I hope this helps - if this doesn't address your situation, please post additional examples of your data and desired results. Thanks!
I have the same problem. Some Columns should be totaled, and others should not be. The only thing I figured out is to Grand Total all columns, then format those cells in the Grand total so that the font color matches the background color. This hides those selected Grand Totals from being viewed and/or printed. I experimented by expanding the Pivot Table rows, and the formatting for the selected cells followed into the new cell(s) and when I removed some of the rows, the formatting followed as well.
Wherever you don't want to show the total columns simply hide the column in the total section. I couldn't find any other way to do it.
Be careful about things like distinct/unique counts. This method helps with percentages, but you don't want to sum or average or otherwise aggregate unique counts. I would prefer to be able to just exclude a total for a single field but haven't found a method to do so.
I think I have a similar situation and a great answer for presentation purposes. I'm billing a customer for unbilled items; my pivot shows Qty, rate, and total missed revenue (qty*rate) for each month. Having a sum of Qty and Revenue makes sense for each month, but totaling the rates of the items doesn't. Pivot table and value options are an all-or-none solution. Rather, I just selected the totals I needed to hide and formatted them with white font color (blue for the grand total). My pivot table looks great now with this band-aid approach.

Resources