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))
Related
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))
I’d like to count how many times a certain company is audited according to a certain standard. If a company XYZ in a column F is audited according to a certain standard in a column C more than 3 times, it should count as 3. If this company is audited 3 times or less, it should count as it is.
Here is the example (column H is the desired result):
I have tried to solve it with the following formula:
=IF(SUMPRODUCT(($F$2:F2=F2)*($C$2:C2=C2))=1,COUNTIFS($F$2:$F$60000,F2,$C$2:$C$60000,C2),"")
However, I only get the results how many times a certain company is audited to a certain standard. The issue with “count no more than 3 times” is missing :-(
I would appreciate any support, no matter whether with a formula or VBA!
Thanks!
You can implement a MIN() statement, e.g: in H2 try:
=IF(OR(C2<>C1,F2<>F1),MIN(3,COUNTIFS(C$2:C$60000,C2,F$2:F$60000,F2)),"")
And drag down. Swap the OR() back to SUMPRODUCT() if need be.
Untested, since I cannot paste your screenshot of data into a worksheet:
IF(
SUMPRODUCT(
($F$2:F2=F2)*($C$2:C2=C2)
)=1,
MIN(3,COUNTIFS(
$F$2:$F$60000,F2,$C$2:$C$60000,C2)),
"")
I've tried summing numbers for the entire column by using the sum() function but I get 0 as an answer due to a string present.
Example :
1.99 USD
22.37 USD
2.49 USD
1.69 USD
Is there a function that only calculates/sum the number?
Thanks
Get rid of the USD from the values in the cell and use a custom number format of,
0.00 \U\S\D
Then sum the raw numerical values.
How about:
=SUMPRODUCT(--SUBSTITUTE(A1:A4," USD",""))
A quick and dirty solution (if you just want to sum them up, without further computations) would be to use the "Search and Replace" function CTRL+H. Silly me for not realizing this earlier.
In my case, it's " USD" with a blank space in front (ignore the open-inverted commas) and inserting nothing at all in the "replace with" parameter.
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.
I'm not the best with technical descriptions but please bear with me.
The task before me:
A large spreadsheet with a column of values that need to be reviewed and a different number input beside them. Unfortunately the number is not simply "value, less 15% though it's close". I will need to have a list of specific "find/replace" commands for my formula.
Example:
3.02
6.65
1.54
3.02
And I need to format it such that it says:
3.02 2.80
6.65 5.60
1.54 1.40
3.02 2.80
My idea was something along the lines of =if(A1=3.02,2.80,=if(A1=6.65,5.60,=if(A1....
Then I'd be able to just paste this formula and drag down the entire spreadsheet.
Unfortunately that didn't work and so I come to you all for help.
Please save me tons of time and figure out how I can make this spreadsheet generate it's own values!
Thanks,
Mike
I would make a little lookup table of the specific replacements:
A B
1 lookup result
2 3.02 2.8
3 6.65 5.6
4 1.54 1.4
5 3.02 2.8
And then you could set up a formula like this:
9 value result
10 3.02 =VLOOKUP(A10,A$2:B$5,2,FALSE)
11 6.65
12 1.54
13 3.02
14 1.54
And you can drag that formula down the rest of the table.
Beware of the A$2:B$5 - if your lookup table is differently-sized, it will need to change.
OR, to keep more along the lines of what you have, try a formula like this:
=if(A1=3.02,2.80,if(A1=6.65,5.60,if(A1....
The change I made was to remove the extra = before the inner IF function calls.
It is hard to guess how many different value do you have. Based on your given sample data you can use XLOOKUP() function like below if you have Excel-365.
=XLOOKUP(A1,{5.6,2.8,1.4},{5.6,2.8,1.4},"",-1)