Finding the total sum based a few criteria - excel

I am currently working with the following excel workbook:
Workbook 1
I wanted a feature where I can find the total number of doors that need fixing, but based on Brand and Model of the cars. For example in the workbook, there are 5 Honda Vios (Blue) that needs to fix 1 door, then 2 Honda Vios (Red) that needs to fix 2 doors. Therefore, is there any formulation (sumifs / countifs) that I can use so that I can easily find the total number of doors that need fixing?

In cell G2 add this formula:
=COUNTIF(E2:F2;"YES")*D2
And drag it down.
This will count the number of doors on this row.
Then create a new table with the unique items and add the following formula which will sum all blue Honda Vios doors.
=SUMPRODUCT((A:A=M2)*(B:B=N2)*(C:C=O2)*G:G)
If "ES" is included:
=(IF(ISNUMBER(FIND("ES",E2)),1,0)+IF(ISNUMBER(FIND("ES",F2)),1,0))*D2
Regarding pivot table.
First make the table a official table by clickin on a cell in the table and go to insert -> table
Then again, click inside the table and go to insert -> Pivot table.
(To make it easier I added the pivot table on the same sheet)
Now set up the pivot as following:
When you add new items to your table, the pivot table must be refreshed.
Click on pivot table and go to Analyse -> refresh

Related

Excel - Pivot Slicer or Via VBA?

I am posting this to all Excel Champs and Code Experts. I am familiar with Pivot and Slicer feature of excel however came with an requirement and I could not think of any way I can achieve it via pivot ( preferably )
The Requirement is like this. I have team data in col 1 and Sales figures in col 2. Now with a simple pivot, I can have the team totals and things like that but I need to put in slicer on team name. If I select Team one , it should show Team one sales against total of other three team . PLease advice if there is a way to do that. In summary I need to compare a person's /team performance against total peers
Team Sales
One 20000
Two 15000
Three 500
Four 35000
One 500
You can achieve this with formula next to your PivotTable values. You will use formula against your total range of values in col2. If your columns are set to range A:B, and PivotTable is in range D:E, then put this formula =E2/(SUM($B$2:$B$30)-SUMIF($A$2:$A$30,D2,$B$2:$B$30)) in cell F2. You should get result as follows.
If you need to have result inside your PivotTable, then you should use PowerPivot and create a measure. try looking at this for more info: https://msdn.microsoft.com/en-us/library/gg399161(v=sql.110).aspx

Excel Slicers for Measures

I have a cube with two measure(count of patients) and (distinct count of visits) , and various dimension(date,program,region,etc), when I browse the cube data from excel, I can choose all the dimensions in the slicer, but my question is is there anyway i can choose the measures in the slicer? From what I see, when I insert a slicer I only get to pick the dimesnions
Any help would be appreciated
I'm not sure of a way around using PowerPivot to do this, short of complicated VBA scripts.
To do it with PowerPivot:
Create a new table with two columns. Column 1 contains the name of your measures and column 2 contains an index for each. e.g.
and add this to the Data Model (but don't create any relationships to any other tables).
Create a new measure with a SWITCH function that has the same relationship between the measures and their values in the Index column, e.g.
[Chosen Measure]:=SWITCH(TRUE, MIN(MeasureTable[Index])=1, [DistinctPatients], MIN(MeasureTable[Index])=2,[DistinctDates])
Add the new measure to the values section of the pivot table and add the
Measure column from your new table to BOTH a slicer AND the column headings in the pivot table and remove the row and column totals.

Excel pivot table - average of calculated sums

I'm sure this is simple, but how do I get a pivot table to display an average for a calculated sum of fields? In the simplified example, I've filtered out fund x1, and the pivot table is showing the sums of the remaining funds per person. Now how do I get an average by person (so, manually calculated, 3300/3)?
I tried using a calculated field, but cannot figure out how it will work because the denominator will change based on how many people will have the funds I'm filtering on. If I use the averaging inside the calculated field it goes back to averaging the funds.
I tried putting the calculation outside the pivot table, and this works, but of course as I filter, my calculated field is no longer adjacent to the pivot table data, instead just floating off on the worksheet by itself.
TIA.
Per request here is the field list - if I try adding an "average of amount" to the value box it averages the fund amounts, instead of the fund amount per person. :
Here is a working solution:
Firstly you should install or enable Power Pivot. Quoting Microsoft:
Power Pivot is an Excel add-in you can use to perform powerful data
analysis and create sophisticated data models.
https://support.office.com/en-us/article/Power-Pivot-Powerful-data-analysis-and-data-modeling-in-Excel-a9c2c6e2-cc49-4976-a7d7-40896795d045?ui=en-US&rs=en-US&ad=US
In newer Excel versions Power Pivot is already installed and you can enable it by going to:
File > Options > Advanced > Data > Enable Data Analysis add-ins: Power Pivot, Power View, and Power Map
Alright, so you have Power Pivot now and you can see Power Pivot tab. Please follow the steps below:
Select your data and click add to “data model” icon on Power Pivot tab.
In Power Pivot window add column which will count distinct number of
persons in the data. =DISTINCTCOUNT([person]) name it for example
“DistPersNo”. This is crucial step – Power Pivot enables you to
count unique values in selected column.
Add another column with formula =[amount]/[DistPersNo] name it
“PersonAverages”.
In Power Pivot window click PivotTable and add new pivot table to
your worksheet.
In Pivot Table add 'persons' to rows and 'amount' to values. Now, if you add 'PersonAverages' to values (sum of it) and filter out fund 'x1' you will achieve desired result i.e. value of 1100.
Hope that helps.
I would add a helper column in column D to count unique customers.
Sort your data by person
In column D2 put =IF(A2=A1, 1, 0) and call the column UniqueCust
Copy formula down your dataset for all rows
Add the column to your pivot
Create a formula in your pivot table called Avg per Cust =Value/UniqueCust
This will flag each row in your data with a 1 if it is the first time a name appears in the column or zero otherwise. The pivot table calculation will sum up the total value and divide by the total unique customers.
I'm assuming that you want the value to come in any pivot table and not in a cell calculated outside the pivot table as a formula.
As a workaround you can use another pivot table, which takes the input as the original pivot table to find the average.
pivot tables
The second pivot table has data source as- E3:F5 or till whatever row you require.
You'll have to refresh all so that the second pivot table reflects any changes in the filter of first pivot table.
I've hidden (or you can filter it out) the grand total in the first pivot table so that the average gives the average of the sum of the amounts.
Since you didn't mention how you are using the data, I will give a couple of options that could work.
If you are the only user of the data or if someone else using the data is pivot table savvy you can use the following field list setups to switch data usage:
Sort by Fund (Note the Fund and Person in the Row labels section)
and Sort by Person (Note the reversed position of Fund and Person in the Row labels section)
To simplify the data, you can always minimize the main fields.
If you are distributing the pivot table to other people who aren't able or willing to modify the pivot table data, I would recommend setting up two separate pivot tables (using the same data source) with the same setups that I showed above.
Click the pivot table to bring up the field list.
In the Values section where it says "Sum of Amount" click the drop down.
Click "Value Field Settings" and choose average from the list in the pop-up.

How can I create a % variance column in Excel 2010 pivot table?

I have a Pivot table containing sales data.
In the Rows I have sales country, in the Columns I have sales date (year) and I have the sum of the invoiced net values in the data section.
Across the top I have two columns - '2012' and '2013' - next to these excel, by default adds a grand total column adding the two years together.
Is there anyway that, instead of a grand total, I can show the percentage variance between 2012 and 2013?
Excel 2010 may be different but if Excel 2007 is better than nothing:
Create your PT in the normal way (Country for Row Labels, Year for Column Labels, Sum of Invoiced for Σ Values).
If present, remove the Grand Totals for rows (Select the PT, Pivot Table Options…, Totals & Filters, uncheck Show grand totals for rows). The Grand Totals for columns may be kept, but the value there in a column to be added would not be meaningful.
Select a column header (say 2013) and in Options > Tools – Formulas select Calculated Item…
In Name: select something suitable (perhaps ΔYonY) and for Formula: enter =('2013' -'2012' )/'2012'.
Set font colour of bottom right-hand cell to match fill.
pnuts' answer is accurate.
If you are looking for a way to have this calculated automatically in the PivotTable, you can use calculated fields.
In order for this option to work, you will likely have to change the way your data is structured.
I'm assuming right now you have a data column with Sales Date. You will need to add one column per year, and assign a value to it in your data. You can then get rid of your invoice column.
Click anywhere inside your pivot table, in the ribbon go to Fields Items & Sets, Calculated field.
In the formula, type in what you need (you can use the fields list to add them in). I did =('2013'-'2012')/'2012'
You can then of course change the formatting to be in %
See screenshot for old vs proposed.

Adding columns to a pivot table in excel

I apologize if my question is vague or was asked before. I have the below table in a spreadsheet
Region Next Service Date Duration Type Duration Frequency
New York 12/4/2013 Year 1
The spreadsheet has 4 columns and what I would like to do is to create a pivot table and somehow project the next 24 months service duration on the pivot table so the output would look like the below
Count of Unit Serial Number Column Labels Continue for
Mar-13 24 Months…
Region
New York Count of Services
Basically, I need to show the count of services for the next 24 months without editing the datasource tab of the pivot table.
As far as I know, you can't add columns to a pivot table.
If someone gives me an idea of how to add columns based on the duration and duration frequency to a pivot table, that would be a great start point.
Thank you all for your feedback and sorry for the misformatted tables
Use this formula
In cell A1 of Sheet2
=Sheet1!A1
Copy and paste as needed, you now have a duplicate of the data sheet, "without editing the datasource".
Create your formulas for projection info on Sheet2, and use Sheet2 as the source for the Pivot Table.
Be aware lots of formulas can bog down Excel, so if at all possible I would put your formulas for projection info on the datsource tab (Sheet1) and hide them. You will still be able to use them in the Pivot table when hidden.

Resources