Subtract two range values for matching ones excel - 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.

Related

Determining a value depending on where you are on a list in Excel

I am tracking the progress of students reading books in class. For the number of books they read they get a reward. It is not 1 book = prize, 2 books = prize. Instead there are dead spaces along the way, for example there is no reward for books 3 and 4 but there is for 5 books. I want to be able to input the number of books each student read and have it update as to what the next reward will be. For example:
List one
Name Books Next Tier Prize
Sally 4 5 Candy Store
Luke 1 2 Extra coloring time
Jane 8 10 10 Extra minutes on the playground
And so on
The table for rewards would be
Books Prize
1 Ribbon
2 Extra coloring time
5 Candy Store
7 Prize bucket
10 10 Extra minutes on the playground
And so on
This is just an abbreviated list and I have used if then statements previously. However the previous list that had 18 values was cumbersome as it was, the new list has 35 values.
I have used if/then statements in the past in combination with vlookup, but with the increased number of values, it just seemed daunting. I could still use an if statement but was hoping there would be an easier way.
Put this in C2 and copy over and down:
=INDEX(F$2:F$6,IFERROR(MATCH($B2,$F$2:$F$6),0)+1)

How to sum through two tables in 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))

Equal distribution formula based on preset values. Excel

e.g. There are 300 apples. There are 100 people. Each person has a preset value (represented as a number 1 to 5). 1=1 apple, if their value is 5 they get 5 apples etc. But there are 300 apples available so each person is going to get more then the value says they "deserve". Or one day there are only 200 apples and every one gets less then what the value states says they "deserve". Is this possible in excel?
NAME VALUE
john 5
james 5
sam 4
matt 5
mike 3
steve 2
etc...
This absolutely sounds like a perfect problem for Solver to handle. As you know, this in included within Excel's addins. It can deal with all the variables you mentioned.

sports scoring in multiple phases in excel

I have a question about excel.
There is a sports tournament with multiple phases. And the results page looks something like this:
rank phase1 phase2
1 TOM ALBERT
2 MATT TOM
3 ROBIN MATT
The first place gets 5 points, second 3 and third 1 points.
So the summary I would like to get is like this
rank name phase1 phase2 total
1 TOM 5 3 8
2 ALBERT 0 5 5
3 MATT 3 1 4
4 ROBIN 1 0 1
I cant figure out how to generate it simply, so if I copy-paste the results from phase3 to somewhere in my excel sheet, the summary page would also update.
If you can support me with advice or just a working template, I would be thankful!
Thank you for your time!
I've done you a basic example below...just list all 50 players in the summary page and copy the formula down as it is - as per the question it only records a value for the top 3 places, hope this helps if not please let me know :)
Example file here
Assuming the structure you defined and that when you paste phase 3 it will have its header ("phase3") on the same row as the other results, you could have the following formula on your Table 2:
{=SUM(IF(IFERROR(MATCH($B2,INDIRECT("Sheet1!"&CHAR(64+MATCH(C$1,Sheet1!$1:$1,0))&":"&CHAR(64+MATCH(C$1,Sheet1!$1:$1,0))),0)-1,0)={1,2,3},{5,3,1},0))}
Note: entered as Array formula: CTRL + SHIFT + ENTER
Formula uses the Table 2 headers ("phase1","phase2", etc.) and the players names to find the results for each phase. It then uses the predefined arrays that determine points given per position. The final sum is to bring the result that are in array (other values in array are 0) into single value.
Total would sum results per player.
Under the rank cells you would place the following formula:
=RANK(F2,$F:$F)
Which would provide you the rank of each player (Column F containing the totals).
Note that this would not sort your rank automatically but you could easily do this with Sorting or Autofilter. Hope this helps. Cheers.

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:

Resources