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!)
Related
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.
I have some data that looks like:
Day Result
1-Nov 1
0
1
2-Nov 1
3-Nov 0
0
4-Nov 1
There are other columns with data. I only have the date once as the data is displayed graphically in a time series.
Now I'd like to setup a summary table that aggregates each day. I cannot use sumifs because the date is only in the data once.
How could I write a calculation such that excel sees a2 has a value so sums b2,b3,...bi until ai has a value.
Preferably not vba, never learned it and want to do this in excel rather than R or Python.
EDIT:
I am specifically looking at how to do calculations on the result column grouped by each date. Blank cells should be considered the same date. So when excel sees 1-Nov it then does a calculation (i've said sum but any we can extend to) on 1,0,1 and then stops and a new calculation is done for Nov-2.
IMHO, instead of using a table like this:
Day Result
01/nov 1
0
1
02/nov 1
03/nov 0
0
04/nov 1
You should populate the "Day" column and use a pivot table to summarize the results.
I.e.:
Day Result
01/nov 1
01/nov 0
01/nov 1
02/nov 1
03/nov 0
03/nov 0
04/nov 1
And the pivot table:
I have two columns as shown below. Group values is 0,1,2,3,4 and scores is from 0 to 80. I want to count how many 0s (1s, 2s, 3s, 4s) are present for scores between 0 and 10; 10 and 20; 20 and 30 etc.
I am thinking to use Excel pivot table. But I am stuck - how could I achieve this?
Group scores
1 8.56163
2 34.3649
2 12.2291
0 8.75357
2 8.75967
2 5.87806
0 9.33751
2 32.0303
0 43.5567
2 11.1044
2 24.9266
1 18.9314
-------- result should look like below --------
scores group count
0-10 0 2
0-10 1 1
0-10 2 2
0-10 3 0
0-10 4 0
10-20 0 0
10-20 1 1
10-20 2 2
...
------ PS I have solved this problem using matlab. But it would be nice to see someone do it in Excel.
---------------- thanks for all the anwers. I really appreciate it. I have accepted the 1st answer.
I apologize for my previous answer. You can do binning with PivotTable.
select your whole two columns (A1:B13), insert PivotTable
under rows, put your "Group"
under columns, put your "scores"
under values, put your "Group"
click that last one ("Group" within the values quadrant) and change it to count, not sum
intermediate result:
Now in the resulting pivot table, right click on a colum and select "Group and show detail". You can configure your bins there.
Result:
One option is to use a pivot table, but another option is to use COUNTIFS, e.g.:
=COUNTIFS($A$2:$A$13,"="&$F2,$B$2:$B$13,">="&D2,$B$2:$B$13,"<="&E2)
In practice:
You could just use simple countif formulas:
Type out first criteria into cells. D1 = 0, E1 = 1, F1 = 2 etc.
Now you can just say =COUNTIF($A$2:$A$13,D1) and just drag that out.
The other column would require countifs.
Lets say D3 is blank E3 = ">10", F3 = ">20", etc.
Now D4 = "<=10", E4 = "<=20", F4 = "<=30", etc.
Now you can use =COUNTIF($B$2:$B$13,D4) for your first criteria and =COUNTIFS($B$2:$B$13,E4,$B$2:$B$13,E3) for the next criteria and just drag that out.
Hope this helps, good luck!
Please try:
This uses Grouping (by decade) for the Row labels.
To Group, right-click on one of the entries under Row Labels and Group..., then select enter Starting at:, Ending at: and By: to suit:
I currently have this in sheet1 columns A,B,C:
Date Time Worker
04/04/2016 4,5 John
05/04/2016 2 John
06/04/2016 6,5 John
07/04/2016 0 --
08/04/2016 0,5 Charles
08/04/2016 2 John
08/04/2016 0,5 William
09/04/2016 0 --
10/04/2016 0 --
11/04/2016 9 John
11/04/2016 3,75 William
I want this in sheet2 columns A,B,C,D (or more in case of more names):
Date Charles John William
04/04/2016 0 4,5 0
05/04/2016 0 2 0
06/04/2016 0 6,5 0
07/04/2016 0 0 0
08/04/2016 0,5 2 0,5
09/04/2016 0 0 0
10/04/2016 0 0 0
11/04/2016 0 9 3,75
I need this because I need to make a graph and data has to be organised like this or I'm not able to create the graph!
The code (which i believe it's the only way) has to work with any given dates, times or worker names! Worker names in alphabetical order if you can.
I don't have any clue how to code this and it is giving me nightmares for weeks. Really need all the help for this one.
It's just a guess since you didn't say what the chart should display.
I am pretty sure you can create this chart without the second sheet and a macro.
Try this:
Format the Range containing the data as table ( Select Range, Home -> Styles -> Format as Table) When you add a new row this table will automatically extend.
Create a Pivot-Chart ( Select all cells in the new table, Insert -> PivotTable (the Name, not the symbol) -> PivotChart)
Choose a destination for the PivotChart
Click in the Pivot-Field and select your 3 entries
It should look like this (I filtered the "--" Workers):
Play around in the 4 fields (drag&drop) to fit it your style. If you add new rows simply right click anywhere in the pivot table and press refresh.
Edit: I forgot to mention that I did this in Excel 2010.
I've been hitting a wall on this today. I'm pulling my data from a SQL DB and in my query I'm setting flags so that I can use the Pivot table to count up all the different checks I'm trying to run on the data. A simple version of what I'm doing would look like this is below with a Greater than 90 days and Error Check flags set depended on the data in Uptime.
Host Team Uptime >90 ErrChk
Srv1 A 15 0 0
Svr2 A 102 1 0
Srv3 B 95 1 0
Svr4 B 20 0 0
Srv5 B 21 0 0
Srv6 B ERROR 0 1
Srv7 A ERROR 0 1
Srv8 B 150 1 0
Srv9 A 100 1 0
Srv10 A 10 0 0
Srv11 A 125 1 0
Srv12 A 40 0 0
Srv13 B 111 1 0
Srv14 B 100 1 0
Srv15 A 15 0 0
If you were to plug this into Excel exactly the way that it is you will see what I'm getting at. Once you create a Pivot table on this data and use the Team as the Rows and the Sum of >90 and ErrChk the pivot comes out and looks correct.
Row Labels Sum of >90 Sum of ErrChk
A 3 1
B 4 1
Grand Total 7 2
But the next piece is where it gets wonky. With a Pivot table when you double click one of the values it filteres down on what makes that value, however when you do it on the value of a SUM, it just filteres down on the Row Label. So for this example you would click 3 under >90 for team A to see what the 3 servers are that have been up for longer thank 90 days. However when you do this it gives drills down to just a filter of team A showing you all of the servers, the good, the bad, the error.
My question is how can I drill down to just the items that make up that value? I've tried all I can think of, have the filed be NULL, 0, calculated fields.
I would suggest adding an additional pivot table for the view you want. For your example you might want to add Team, then Host to Row Labels. Then add Sum of > 90 to Values. Then add > 90 to Report Filter and set the filter to 1.
These pivot tables could all be on the one worksheet pulling from the same data source as a kind of summary and the filter would be preset so there would be no need to provide instructions to those viewing the summary.
If you'd like let users change the filter easily you could add a slicer which will present all options by which the data can be filtered by.