Group by Sum in Excel - excel

Let's assume that I have the following table in Excel
A B
Item quantity_sold
A 3
A 4
A 1
B 5
B 2
D 12
C 3
C 7
C 8
and I need to sum up quantity_sold grouped by Item and print the results on the adjacent column only once per group, similar to the following
A B C
Item quantity_sold SUM_by_item_type
A 3 8
A 4
A 1
B 5 7
B 2
D 12 12
C 3 18
C 7
C 8
Is there any way I can achieve this without using Pivot Tables?

Try this formula in C2 copied down
=IF(A2=A1,"",SUMIF(A:A,A2,B:B))
That will give you a sum on the first row of each group - other rows are left blank

I'd create a smaller table alongside (or on a different sheet) and use
=SUMIF(A:A,"A",B:B)
where...
=SUMIF(different-item-range,"what you're looking for",things-to-add-together)
=SUMIF is all explained here: http://office.microsoft.com/en-gb/excel-help/sumif-function-HP010062465.aspx

Subtotal feature:
Click the Data tab in Excel's ribbon toolbar
Click the Sort button and sort by your category column
Click the Subtotal button and fill in the dialog as appropriate,
then click OK
Video example: https://www.youtube.com/watch?v=OBj30n_x5aQ

Related

Convert sql to excel formula

I have 2 tables in excel.
Table 1
Item Quantity_Required Quantity_Remaining
A 5
B 10
C 3
Table 2
Source Item Quantity
1 A 2
2 A 1
1 B 5
My result should be to fill in Quantity_Remaining column in Table 1
Table 1
Item Quantity_Required Quantity_Remaining
A 5 2
B 10 5
C 3 3
The logic in SQL code is as follows.
SELECT A.Item,
A.Quantity_Required,
A.Quantity_Required - B.Quantity as Quantity_Remaining
FROM Table1 A
LEFT JOIN
(SELECT Item,
SUM(Quantity)
FROM Table2
GROUP BY Item) B
ON A.Item = B.Item
I need pointers on how to translate this to Excel.
For data placed in excel sheet like below, you can use this formula:
=$B2-SUMPRODUCT(($A2=$B$8:$B$10)*($C$8:$C$10))
So the second part of formula SUMPRODUCT is looking for cells in range B8:B10 which match with A2 and then taking their values from column C and adding them.

I want to get the sum of count of each unique entry from a particular column from google sheet

I have a google spread sheet,I want to get the sum of count of each unique entry from a particular column('Text' in this example).However the entries in the column themselves repeat.
Eg:
Text Count
a 3
b 4
a 8
abd 4
c 1
t 2
abd 5
a 2
v 1
v 67
w 44
I want the output as:
Text Count
a 13
b 4
abd 9
c 1
t 2
v 68
w 44
Under the assumption that you want to get the results in the text column automatically, use a Pivot table in Excel:
Mark your data including the column captions "Text" and "Count"
Go to the "Insert" tab in the ribbon, hit the arrow below and choose "PivotChart and PivotTable"
The cells for the raw data should already be entered. In the lower part of the window choose where you want to get the Pivot table. Then hit Ok.
There should be an area on the right-hand side of the window where you can choose which data you want to evaluate. Choose Text and Count.
There should already be the sum of the Count values. If you want to get a different quantity such as the average, hit "Sum of Count" with the right mouse button and
You need a GROUP BY and a SUM:
SELECT text, sum(count) as count
FROM yourtable
GROUP BY text

Sum values if multiple conditions met in different sheet

I have one sheet that creates a mapping of names to values (Map_Sheet). In another sheet there are values for each name in the mapping table (Data_Sheet). What I am trying to do is add values based on certain conditions in the mapping table. For example: I want to add all counts of dog by bread and color. So in the mapping table I would look for all dogs that are brown and of a certain bread and get their names and manually add them together. I want to have a formula that does the addition based upon multiple conditions from Map_Sheet.
Here is an example of the data:
Map_Sheet-
name|bread|color|age
a x b 2
b y w 3
c x b 2
d z f 4
Data_Sheet -
id|a|b|c|d
0 3 4 2 1
1 1 2 4 2
2 3 5 7 2
3 1 2 6 9
4 1 3 5 7
And for each ID in the data sheet I want a count of bread X with color B. So I would add for ID0 values for A and C, (3+2) - so ID0 = 5, etc for each id.
I cannot use VBA so I was looking into using INDEX and MATCH but I cannot wrap my head around it. Any ideas? Thanks!
If the row headers in the first sheet match the column headers in the second sheet, you can put this formula in (say) G2 of the second sheet.
=SUM(TRANSPOSE(Map!$C$2:$C$5="b")*C2:F2)
If the column headers in the second sheet were in a different order, you would have to use something like:-
=SUM(C2:F2*NOT(ISERROR(MATCH($C$1:$F$1,IF(Map!$C$2:$C$5="b",Map!$A$2:$A$5),0))))
Both of these are array formulae. You can add extra conditions to select breed as well as colour using the same basic pattern:-
=SUM(TRANSPOSE((Map!$C$2:$C$5="b")*(Map!$B$2:$B$5="x"))*C2:F2)
or
=SUM(C2:F2*NOT(ISERROR(MATCH($C$1:$F$1,IF((Map!$C$2:$C$5="b")*(Map!$B$2:$B$5="x"),Map!$A$2:$A$5),0))))

agregate in vertical 2 or more colums in EXCEL

I'm looking for a way to take these columns (Name/value)..
Name Value Name Value
a 1 c 3
b 2 d 4
and join them together as follows:
Name Value
a 1
b 2
c 3
d 4
Thanks
A PivotTable constructed with multiple consolidation ranges (one for each pair) would achieve the result you want (but might be little easier that copy and paste):

Excel: Arrange Rows to Match Another Row

I have a database with a column A with some values, and then 2 additional columns: Column B contains a bunch values that will match the ones in column A, but are not in order. I also have a Column with information that pertains to that specific row, amnd would like it to stay in 'sync' with column B. For example:
| A | B | C |
1 3 A
2 1 F
3 2 D
4 5 R
5 4 P
I'd like a way to sort it so my result would be:
| A | B | C |
1 1 F
2 2 D
3 3 A
4 4 P
5 5 R
Is there a way to do this?
If possible, if there is no match, delete the row?
In Excel 2007/2010,
simply select the cell with the "B" in it and go to the Data tab along the top and click on the A to Z button which is near the middle of the data tab. As long as B & C are adjacent columns, they will sort according to your needs. Please Note, Column A must not be adjacent to the other 2, otherwise you would run through the same procedure above but you would highlight columns B and C and perform the same sort button steps. If it gives you a Sort Warning, click the "Continue with the Current Selection" radio button and OK.

Resources