I have two Excel tables that look like this:
Table 1
A B C
ID Stocked Sale
1 shelf sold
5 display sold
9 shelf sold
12 shelf sold
13 shelf
Table 2
P Q
ID Stocked
a2 apple
88
83
1 apple
9 apple
I need to count the total number of apples by common ID, given that apples are:
stocked on the shelf in Table 1
sold in Table 1
So, the outcome has to be 2 apples.
Here is what I have tried thus far:
COUNTIFS(B:B, "shelf", C:C, "sold", Q:Q, "apple")
I can't figure out how to count by common id...
Something like this should work for you:
=SUMPRODUCT(COUNTIFS(A:A,REPT($P$2:$P$6,$Q$2:$Q$6="apple"),B:B,"shelf",C:C,"sold"))
Related
I am wondering , if I can write a formula which would operate over several columns, e.g. I want to calculate the amount of males in the school and I have a table:
A B C
Class Sex Number
1 male 3
2 male 4
1 female 6
2 female 5
Right now I have to break the operations into parts:
=(B2="Male")*C2 - additional column and then
=SUMME(D2:D5)
I want to do it at once. It seems like a trivial functionality, but I can not figure it out, how I can do it in one formula.
I am working on an excel sheet that will help me with meal-planning. Currently, I have my data stored in a manner like demonstrated below:
**Monday**
Breakfast Bagel 1 Cream Cheese 1
Lunch Spinach 1 Eggs 4 Cream Cheese 1
Dinner Pork 1 Eggs 2
**Tuesday**
Breakfast Cereal 2 Milk 1 Eggs 3
Lunch Bagel 1 Butter 1
Dinner Eggs 2
CURRENT OUTPUT:
Ingredients Needed:
Eggs 2
Bagel 2
Spinach 1
Pork 1
Cereal 2
Milk 0
Butter 0
Cream Cheese 0
Where the numbers represent the number of servings of each ingredient I need to buy.
The problem I am facing is that my current formula:
=INDEX($C$12:$C$58, SMALL(IF(ISNUMBER(SEARCH($B$60, $B$12:$B$58)), MATCH(ROW($B$12:$B$58), ROW($B$12:$B$58))), ROW(B1)))
Only indexes one row at a time. For example, if I am searching for how many Eggs I need to buy for the week, the formula would return 2 eggs (because it is only searching column B for Eggs and returning column C).
Is there a work-around that would allow me to be able to return the full number of ingredients I need to buy? I realize I could index each column individually, however, since I have many ingredients (100+), using my current formula doesn't seem feasible.
Any help is massively appreciated
You can use SUMIF, where the sum range is offset from the criteria range. For example, for simplicity, let's say that C12 to H19 contains the data (ingredient and quantity), try...
=SUMIF($C$12:$G$19,B60,$D$12:$H$19)
...where B60 contains the ingredient of interest. Notice that the sum range D12:H19 is offset from the criteria range C12:G19.
When I use FIRST(CG1) in 'Cell Values' the grand total is not summing up instead its showing one of the values from the result of FIRST(CG1).
Please advise if we have to always use sum(XXX) to get the grand total summed up.
Short answer, yes if you want the Grand Total to be a summation of your data. Applying a grand total to a different aggregation will have different results.
AVG will average the averages of your Category Axis
MAX will take the MAX of the Max for each category
Cumulative Sum will take the "Last" value in your Category since it doesn't have any additional values to SUM up.
Product will take the Product of Products
First and Last you are already aware of.
Long Answer:
You actually CAN sum the first value of a column from a column grouping.
For example, consider the following data set.
[Grouping] [Food] [Color] [Weight]
Fruit Apple Yellow 4
Fruit Apple Green 2
Fruit Apple Red 4
Fruit Banana Yellow 5
Fruit Banana Brown 2
Fruit Orange Orange 3
Vegetable Carrot Orange 4
If, in your custom expression, you put
Sum(if(RankReal([Grouping], "ties.method=first", [Food]) = 1, [Weight], 0))
it will find the first instance of each food in your data set, so regardless of how you group the left, your results, subtotals, and grand totals will sum only the first instance of each food.
So you will be able to see the following:
Fruit Apple 4
Banana 5
Orange 3
Subtotal: 12
Vegetable Carrot 4
Subtotal: 4
Grand Total: 16
I'm not sure how I would go about creating a macro (or maybe even an Access query?) for what I'm looking at here. I have a spreadsheet of tens of thousands of customer names/numbers with product data. If a customer has bought two (or more) products, it reflects as multiple entries on the spreadsheet (example below).
Name # Product
----------------------------
Bob 101 Product 1
Joe 102 Product 3
Bob 101 Product 2
Bob 101 Product 3
Hank 103 Product 2
Susan 104 Product 1
Hank 103 Product 3
I want to run something on that spreadsheet that combines the entries into one line, such as the example below. I'm not concerned about how the "products" are delineated... comma, line break, space, whatever. But I would like the end result to look something like this
Name # Products
-----------------------------------------------
Bob 101 Product 1, Product 2, Product 3
Joe 102 Product 3
Hank 103 Product 2, Product 3
Susan 104 Product 1
But I'm not even sure where to start. Any ideas to at least get me in the right direction?
Sort on Product within Name and in D2 (?):
=IF(A1=A2,D1&", "&C2,C2)
in E2:
=A2<>A3.
Copy both down, select all, Copy, Paste Special, Values over the top, filter to select FALSE for ColumnE and delete all visible.
I'm working on Excel with a lot of data and I'm having difficulty with knowing how to sort through it to get some important numbers. I have minimal Excel experience.
Right now I'm struggling with knowing how to get the average in the difference between two columns. The trick is that I have to get the average in difference when column A is less that column B and then, the same when it's more. And all that within a category.
So for example let's say I have 3 categories: Football, Soccer, and Basketball (these are just made up ones).
So in column A, I have: Soccer, Football, Basketball. Then, in column B and C, I have the scores for John and Adam for the last 3 months, respectively. Lastly, in column D, I have the differences between their scores.
So, for example:
Category John Adam Differences
Soccer 5 3 2
Soccer 6 2 4
Soccer 3 5 2
Soccer 4 0 4
I want to create a table for within each category I have a table like below:
NÂș of cases Avg. Difference between John and Adam
When John's score is >
When John's score is <
When they are equal
Is there some type of formula where I can say something like this:
If the category is Soccer (the category being in column A), take the difference between John's score (column B) and Adam's score (column C) when John's score is larger than Adam's score, then calculate the average of those differences? Then, I would use the same formula but tweak it when John's score is smaller.
Additionally, would there be a formula where I can also, calculate within the category Soccer, how many times John's score is bigger than Adam's?
My data is much larger and I can't do this manually.
A B C D
1 Sport John Adam Differences
2 Soccer 5 3 2
3 Soccer 6 2 4
4 Soccer 3 5 -2
5 Soccer 4 0 4
6 Basketball 20 15 5
7 Basketball 7 13 -6
8 Basketball 26 10 16
9 Basketball 8 11 -3
Type in D1:
=B1-C1
Drag the formula in Column D to all rows which there are values in columns A, B and C.
Create the PivotTable.
Drag Sport to "Row Label" field. Drag Differences to "Row Label" field under Sport.
Drag Differences to "Values" field as: Count of Differences (same way the previous question)
Drag Differences to "Values" field (below Count of Differences), and set the mathematical operation as "Average" of Differences (left-mouse click Differences, choose "Values fields settings" and select "Average").
Give a right-click mouse in cell A5 (see picture bellow) and select "Group" option.
Set "Starting at" = 0; "Ending at" = 1000; "By" = 1000 (as in the picture below). Click ok.
You will have in each Sport, the count (frequency) and average Differences values for two groups:
When the Difference B1-C1 is negative; and
When the Difference B1-C1 is zero or positive.
The average of Differences when the score is equal will be always zero.