How to sum through two tables in Excel - excel

I am looking for help to sum values in a table using a mapping table..
Tried Xlookup and sumif. Not sure where I am going wrong.
Simplifying it in an example
Basically, I have two tables.
Food type
Food
Fruits
Apple
Fruits
Orange
Vegetable
Spinach
Vegetable
Fenugreek
Food
Cost
Apple
$10
Orange
$15
Spinach
$20
Fenugreek
$10
So, if my input is Foodtype = Fruits, then I should get an answer of $25 (as it will sum up Apple and Orange)..
The combination of sumifs and xlookup is only giving one answer ($10) whereas I need $25.
please let me know.
I cannot combine the tables, as I have to use the first mapping table in multiple places.
Thankyou!

You can try:
=SUM(SUMIF(E2:E5,FILTER(B2:B5,A2:A5=I2),F2:F5))

This uses XLOOKUP and SUM.
=SUM(XLOOKUP(FILTER($B$2:$B$11,$A$2:$A$11=G2),$D$2:$D$5,$E$2:$E$5))

Related

Subtract two range values for matching ones excel

I have come across of the problem that, I don't know how to solve in efficient way. So I have two tables like these:
Table 1
Company Score
Apple 10
Banana 5
Kiwi 4
Pineapple 2
Table 2
Company Score
Apple 4
Pineapple 3
Kiwi 2
Strawberry 1
Then in my result table in which I have company names listed in one column, like below. Right next to this I would like to show the differences which should be the first table values - the second table values where company names match(the list can be in different order that is why, I need to check it before subtracting).
Table 3
Company Result
Kiwi 2
Apple 6
Banana -5
Pineapple -1
I can do this with nested IF function to check every cell one by one, but I assume there might be more efficient way. I wonder if you have one.
Thanks to #ScottCraner's comment, I solved it with two sumifs subtracted from one another with this formula. I entered this in Column D66 and dragged down
=SUMIF($C$36:$C$45;$C$66:$C$75;D$36:D$45)-SUMIF($C$51:$C$60;$C$66:$C$75;D$51:D$60)
1st Sum if: Where C36-C45 is my first list of companies, C66-C75 is the list of companies that I have in the results table, D36 -D45 is the score list from the first table.
2nd Sum if: Where C51-C60 is my second list of companies, C66-C75 is the list of companies that I have in the results table, D51 -D60 is the score list from the second table.

find specific cells according to an order with constraints

i need help on excel
i have table looking like this(it's an example):
cheese tomato chocolate cream
Pizza 2 3
cake 1 1
And i want to have names of ingredients for each plates from the highest one to the lowest if we consider that the numbers are the lead time for each ingredient and if the lead time is the same i don't want to have the same name in both cells.
like this:
Ingredient 1 Ingredient 2 ingredient3
pizza tomato cheese nothing
cake chocolate cream
thank you, please help :)
Try the formula as shown in the image,
=IFERROR(INDEX($B$1:$E$1,MATCH(LARGE($B2:$E2,COLUMN(A1)),$B2:$E2,0)),"nothing")
Am not sure how you want to represent data if the lead time is same. The formula currently shows chocolate twice. You may have to alter it according to your needs. Drag the formula to right and then down for the complete range.

OR criteria with DAVERAGE

Given a large number of entries like the following:
type quantity
apple 3
orange 6
pear 2
pear 2
orange 1
...
I know I can create a pull down menu where I can select any type, say 'apple' or 'orange' and get the average quantity for that specific type: to do so, I use daverage where the criteria is a cell with data validation (i.e. whose content is controlled by a pull down menu).
But what I would also like to have in my pull down menu is an entry 'apple or orange' which when selected gives me the average quantity for apple and orange combined.
I know I can use daverage to compute that number but I don't know how to use that in combination with a pull down menu to achieve my final goal so that by simply modifying the content of cell controlled by a pull down menu, I can obtain the average for either orange, or apple, or orange and apple combined. Is there a way?
I'm posting an answer regardless because though not suitable for you it may be suitable for others in a similar (but not identical!) situation:
Including blanks in data validation can have drawbacks but if applied only to the selection criteria (highlighted yellow) this can be advantageous (two blanks in A2:A3 and the overall average is shown). Treating apple and orange separately rather than as orange-apple is simpler (does not require your workaround) and flexible – any pair (rather than pear!) could be chosen without extending the validation list.
Following pnuts' suggestion and the very same example data: I added a column isAppleOrOrange, computing yes or no using a following formula like this:
=IF(OR(A6="apple",A6="orange"),"yes","no")
This way, if you specify 'yes' in B2, you get the average for apple + orange combined. You can still specify any fruit you want in B1 to get the average for a specific fruit alone but need to make sure isAppleOrOrange is left blank in that case:

sum if with some conditions

Guys here's what I want to do...
I have 3 columns: category, product and quantity. A product can be in more categories... what I want to do is to sum the quantities for each product in each category... I can do SUMIF looking for the product as a criteria but then it will count it no matter the category... do you have any solution? (I don't want to use a pivot because then it will be simple...)
To give you an example let's say we have 3 categories... t-shirts, pants and shoes and 3 brands... let's say one is nike and we have it in all three categories... I want to sum the quantities of nike pants ... the quanties of nike t-shirts and the quantities of nike shoes... if I do a SUMIF with nike as a criteria it will sum everything no matter what they are.
Thanks!
Here's an example:
Let's say we have the following table
I want the following result
Depends on what you want to be simple. Like Brett said, a pivot table is the easiest to implement.
Another solution is to use SUMPRODUCT. The below would find the matches for Category A Product 1.
=SUMPRODUCT(--(A2:A11="A"),--(B2:B11=1),C2:C11)
SUMPRODUCT is well outside of easy I'd say.
A basic PivotTable will produce this summary for you
I suggest you see Debra Dalgleigh's site here for the background info - it won't take long to create

Excel countif where criteria is on separate columns

A B C
1 Fruit 0.34 Pear
2 Vegetable 0.62 Lettuce
3 Fruit 0.80 Apple
4 Fruit 0.86 Banana
Given the table above, I need to know the cost of all items above by type (fruits vs vegetables). In the above example, I'm looking for a formula that gives me Fruits=2.0 and Vegetables=0.62 and can apply to any number of rows.
Any help would be appreciated!
This might be a SuperUser question, but if I understand correctly, this should do the trick:
=SUMIF( A1:A99, "=Fruit", B1:B99 )
and
=SUMIF( A1:A99, "=Vegetable", B1:B99 )
SUMPRODUCT will do what you need, here is an example:
=SUMPRODUCT(--(A1:A4="Fruit"),--(B1:B4))
This link has more on the syntax and how can be used as Excel's help file is lacking when it comes to SUMPRODUCT.
A slight generalisation on palswim's answer will work for any number of rows:
=SUMIF(A:A,"Fruit",B:B)
=SUMIF(A:A,"Vegetable",B:B)
or a formula you could put in column D:
=SUMIF(A:A,A1,B:B)
This may not be the correct forum for that question, but the solution is using "Array Formulas" - Ctrl+Shift+Enter on something like =sum(if(A1:A4="Fruit",B1:B4,0))

Resources