Sumifs, but only on once for each set of matching values - excel

I am extracting sums from a table, and there is one thing I can't figure out how to do: I need to get the results only once no matter how many times there is a match.
For example, I need to sum the total of column C for all rows where A and B both match the values of current row, but I need to get the answer only ONCE, not on every row where they match, although it doesn't matter which instance it is (first, last, middle, etc.).
Sample Table:
1 | 100 | 4.0
1 | 100 | 7.3
1 | 200 | 9.5
2 | 100 | 4.7
2 | 200 | 9.0
2 | 100 | 9.1
2 | 100 | 7.4
I would want to get the results (assuming they showed at the first match):
11.3
0.0
9.5
21.2
9.0
0.0
0.0
How do I do this?

I've tested this and it works:
=IF(COUNTIFS($A$2:$A$8,A2,$B$2:$B$8,B2)=COUNTIFS($A2:$A$8,A2,$B2:$B$8,B2),SUMIFS($C$2:$C$8,$A$2:$A$8,A2,$B$2:$B$8,B2),0)

regarding the comments:
oh true.... messed up the true/false part...
=IF(COUNTIFS(A$1:A1,A2,B$1:B1,B2),0,"here comes your sumifs")
so for your whole formula:
=IF(COUNTIFS(A$1:A1,A2,B$1:B1,B2),0,SUMIFS(C:C,A:A,A2,B:B,B2))
to get the solution always at the first line. ;)

Related

Split columns by groups in Excel

I have a list of groups, subgroups and items in one single column that I would to split in three columns. as the example below:
Class, order and family | Quant.
1. Mammals | 10
1.1 Primates | 6
1.1.1 Lemuridae | 4
1.1.2 Lorisidae | 2
1.2 Carnivora | 4
1.2.1 Felidae | 3
1.2.2 Hyaenidae | 1
I would like to split in columns following the number order, like that:
Class | Order | Family | Quant.
1. Mammals | 1.1 Primates | 1.1.1 Lemuridae | 4
1. Mammals | 1.1 Primates | 1.1.2 Lorisidae | 2
1. Mammals | 1.2 Carnivora| 1.2.1 Felidae | 3
1. Mammals | 1.2 Carnivora| 1.2.2 Hyaenidae | 1
I already separeted numbers from text using RIGHT function, but I do not know what to do next.
Edit for multi digit indexes.
Assuming the source table is in A1:B15 and the result table in E1:H15, the following formulas work:
for Class (E2)
=IFERROR(INDEX($A$1:$A$15,AGGREGATE(15,6,1/(((LEFT(F2,FIND(".",F2)) & " ") = LEFT($A$1:$A$15,FIND(".",F2)+1)))*ROW($A$1:$A$15),1)),"")
for Order (F2)
=IFERROR(INDEX($A$1:$A$15,AGGREGATE(15,6,1/(((LEFT(G2,FIND(CHAR(1),SUBSTITUTE(G2,".", CHAR(1),2))-1) & " ")=LEFT($A$1:$A$15,FIND(CHAR(1), SUBSTITUTE(G2,".",CHAR(1),2)))))*ROW($A$1:$A$15),1)),"")
for Family (G2)
=IFERROR(INDEX($A$1:$A$15,AGGREGATE(15,6,1/((LEN($A$1:$A$15)-LEN(SUBSTITUTE($A$1:$A$15,".",""))=2)*(COUNTIF($G$1:G1,$A$1:$A$15)=0))*ROW($A$1:$A$15),1)),"")
for Quantity (H2)
=IFERROR(VLOOKUP(G2,$A$1:$B$15,2),"")
simplest way i can think off is, if the data above is in cells A:B then the following to be entered in Cells D:G (Headers in first row): -
D: - =IF(SEARCH(" ",A2,1)=3,A2,D1)
E: - =IF(SEARCH(" ",A4,1)=4,A4,E3)
F: =IF(SEARCH(" ",A4,1)=6,A4,F3)
You will then have to delete the first couple of rows for each change in Class/Order.
G: to have a = to the Quantity.
Hope this helps.
Note this way would only work if no number exceeds single digits, if it does let me know and i will make it a bit more intelligent :)

Is there a way to convert a date as 2008.5 (the middle of the year 2008) in a proper date with excel?

I have a series of values (concentrations of ions in the atmosphere) each plotted in function of their date that looks a little bit like this
+---------+----------+---------+
| Year | Sulphate | Nitrate |
+---------+----------+---------+
| 2008.0 | 22.8 | 12.5 |
| 2007.75 | 13.5 | 13.4 |
| 2007.5 | 10.2 | 12.7 |
| 2007.25 | 19.4 | 10.3 |
| 2007.0 | 25.4 | 12.4 |
+---------+----------+---------+
is there a way to convert the year in a proper date? Like, 2008 should become 01/01/2008 (first of jan of 2008) etc.
If you want to display a proper date (middle of the year, a quarter of the year, etc.) then you can try the following formula:
=DATE(LEFT(A1,4),1,1)+(DATE(LEFT(A1,4)+1,1,1)-DATE(LEFT(A1,4),1,1))*MOD(A1,1)
Here's the result:
Another method, that might come a bit closer:
=DATE(INT(A2),MOD(A2,1)*12+1,MOD(MOD(A2,1)*12,1)*30+1)
The formula assumes all months have 30 days.
Understand that, because months have different numbers of days, that a formula like this may not always give an "exact" result.
is there a way to convert the year in a proper date? Like, 2008 should become 01/01/2008
Yes, with the Function DATE:
DATE Function
Also with function LEFT to get the first 4 chars.
LEFT Function
My formula in B2 is:
=DATE(LEFT(A2;4);1;1)
Hope this helps.

To find the minimum and maximum corresponding value in between a range of clubbed values

I am having a small issue with writing a formula. I have my data in this format :
NAME | EXP | SALARY
A | 0.3 | 40000
B | 4.7 | 490000
C | 2.6 | 220000
D | 3.9 | 34000
E | 1.3 | 150000
F | 3.2 | 300000
G | 0.8 | 90000
H | 1.9 | 170000
I | 2.1 | 260000
J | 4.1 | 390000
this is what i want in my output :
EXP-RANGE | MIN SALARY | MAX SALARY
0-1
1-2
2-3
3-4
4-5
i want to find the minimum and maximum salary of people in the experience range
i tried using MIN(IF(<&>)) but it returns #VALUE?
i can also push all this data in to a Database and query it but I would greatly appreciate anyone who could formulate it so that i can work on Excel itself. Data size is 20000+ so i wouldn't prefer filters
Thanks in advance
Use MAXIFS and MINIFS:
=MINIFS(C:C,B:B,">="&LEFT(G2,FIND("-",G2)-1),B:B,"<"&MID(G2,FIND("-",G2)+1,LEN(G2)))
=MAXIFS(C:C,B:B,">="&LEFT(G2,FIND("-",G2)-1),B:B,"<"&MID(G2,FIND("-",G2)+1,LEN(G2)))
If one does not have MAXIFS or MINIFS we can use AGGREGATE:
=AGGREGATE(15,7,$C$2:$C$11/(($B$2:$B$11>=--LEFT(G2,FIND("-",G2)-1))*($B$2:$B$11<--MID(G2,FIND("-",G2)+1,LEN(G2)))),1)
=AGGREGATE(14,7,$C$2:$C$11/(($B$2:$B$11>=--LEFT(G2,FIND("-",G2)-1))*($B$2:$B$11<--MID(G2,FIND("-",G2)+1,LEN(G2)))),1)
AGGREGATE is an array type formula and the references should be limited to the data set.
Assume "Lookup table" put in A1:C11
Criteria with header in G1:G6
In H2 (Min wage), formula copied right to I2(Max wage) and all copied down:
=AGGREGATE(14+(COLUMN(A1)=1),6,$C$2:$C$11/($B$2:$B$11>=IMREAL($G2&"i"))/($B$2:$B$11<-IMAGINARY($G2&"i")),1)
Edit : In convert the criteria "0-1" to complex number "0-1i", the IMREAL() extract the left side number "0", and the IMAGINARY() extract the right side number "1"
=AGGREGATE(14+(COLUMN(A1)=1),6,..., return in Column K =AGGREGATE(15,6,….) and column L =AGGREGATE(14,6,….)

Obtain average based on multiple criteria from table column

I have a table that more or less looks like this:
Team_Name | Total_Errors | Total_Volume
_______________________________________
Sam | 3 | 1350
Sam | 5 | 1100
Jamie | 7 | 1600
Mark | 3 | 1220
Jamie | 10 | 2100
Mark | 5 | 1300
Sam | 5 | 1100
Jamie | 3 | 1900
Just with a lot more rows. I want to create a formula that calculates the average total_errors for just the numbers corresponsding to Team_names "Jamie" and "Sam".
How do I do this?
Something like Average(If(June(Team_Name)="Jamie","Sam"......?
(the table name is June)
thanks in advance
You can use Sum/Count:
=(SUMIF(A1:A8,"Jamie",B1:B8)+SUMIF(A1:A8,"Sam",B1:B8))/(COUNTIF(A1:A8,"Jamie")+COUNTIF(A1:A8,"Sam"))
I would go with a simple pivot table that uses June as a data source.
Put your Team_Name filed as a rows, and Total_Errors as Values. Change the Field settings of your Total_Errors to be an average, and change how many decimal points you want to see.
You can then apply whatever filters /Slicers you want and get your desired result.
Here's a screenshot (its on MAC, but you'll get the idea)
Assuming DATA in located at A1:C9 enter this formula at F5, note tat the Criteria Range used by the formula is locaed at E2:E4 (see picture below):
=DAVERAGE($A$1:$C$9,$B$1,$E$2:$E$4)

Display Value in cell Y based on greater than, less than of cell X

Here's the scenario. I have a large spreadsheet of candidates for NHS at my school that are given a score by several teachers, community members, etc. I average out their score and then based on that number they are given a score/value from a rubric. I am looking for a formula that will read the value of cell X (their average score) and display a specific value in cell Y(their rubric score). The following is the criteria:
value<2.0, display 0
value>2.0 value<3.0, display 1
value>3.0 value<3.5, display 2
value>3.5 value<3.75, display 3
value>3.75, display 4
I tried looking this up and the closest I found was a formula that I modified to look like this:
=IF(I10="AVERAGE_CHARACTER",IF(I10<2,0,IF(AND(I10>2,I11<3),1,IF(AND(I10>3,I11<3.5),2,IF(AND(I10>3.5,I11<3,75),3,IF(I11>3.75,4,0))))))
All it says is FALSE in the cell. Not sure if I'm using the wrong formula or have a typo in the formula. Thoughts? If there is an alternate or easier method, I'm open for suggestions.
Thanks!
source: http://www.excelforum.com/excel-formulas-and-functions/575953-greater-than-x-but-less-than-y.html
It's easy if you keep the thresholds and the rubric in separate arrays:
=LOOKUP(A1,{0,2,3,3.5,3.75},{0,1,2,3,4})
You might use something like: (value to be changed in A1)
=VLOOKUP(A1,{0,0;2,1;3,2;3.5,3;3.75,4},2)
or having a table like this: (value to be changed in C1)
| A | B |
1 | 0 | 0 |
2 | 2 | 1 |
3 | 3 | 2 |
4 | 3.5 | 3 |
5 | 3.75 | 4 |
=VLOOKUP(C1,A1:B5,2)

Resources