Finding the max and average difference - excel

I have a small data-set with reference values and measured values
0 0.017
5 5.2
10 11.2
15 14.4
20 20.5
25 25.5
30 31.2
35 37.6
40 40.2
42 42.8
44 43.1
46 44.7
48 47.2
50 50.3
52 53
I would like to know what the max difference and the average difference is between the reference and measured data. How is this done in Excel?

You can get the Max difference using an array formula. You will need to hold Control + Shift when you press Enter after typing the array formula in the cell where you want to compute that value. If you don't hold Control + Shift while entering the formula then it won't work correctly.
For example, if you have the referenced values in A1:A15 and measured values in B1:B15, you can type =Max(Abs(B1:B15-A1:A15)) into a cell, then hold Control + Shift and press Enter to enter the formula as an array formula. That will give you the maximum difference between the values, regardless of whether the measured value is higher or lower than the referenced value.
The Average can be done the same way, just use =Average(Abs(B1:B15-A1:A15)) instead.

How about
=MAX(ABS(reference-measured))
entered as an array formula CTRL-SHIFT-ENTER

Related

Dynamic score within range based on value

I am attempting to score a record based on where it's value falls within a range. I know I can create a lookup table but that would be rather time intensive and was hoping for additional options.
Example:
Lower bound of 0
Upper bound of 90
Record has a score of 67
What I want to do is score that record between 1 - 3 based on where the value of 67 falls within the range of 10 - 90. So in this instance this record would score a 2.25, or the like.
Thank you in advance for your assistnace!
This is a simple linear equation
With 67 in A1, in A2 enter:
=A1*0.025+1
and then apply rounding.
The 0.025 comes from =(3-1)/(90-10)
The above chart shows the mapping of records between 10 and 90 into scores between 1 and 3.
Assuming the score is linear, the following formula should work
=Record/(UpperRange - Lower Range)*2+1
In the example you give, this would be: 67/(90-10)*2+1 and the result would be 2.675
If you want the scores to go from 1 to 3, in 0.25 increments, with a lower bound of 0, and upper of 90, then:
=ROUNDDOWN(SCORE/(90/8),0)*0.25+1
Which gives 2.25

Automate MIN and MAX temperatures for a certain date

I have big amount of data (60k rows) in Excel that is similar to this:
Temperature Humidity Date
20.1 68 22-dec-14
20.3 67 22-dec-14
20.4 65 22-dec-14
20.0 64 23-dec-14
20.5 64 23-dec-14
20.9 65 24-dec-14
21.4 64 24-dec-14
23.4 64 25-dec-14
23.8 65 25-dec-14
23.9 64 25-dec-14
18.4 64 25-dec-14
I created new columns outside this table that contains the individual dates and I want to extract the MAX, MIN and possibly the AVERAGE of that date
DATE MIN MAX AVG
22/Dez/14
23/Dez/14
24/Dez/14
25/Dez/14
I tried but I can't seem to find a way for Excel to work for me. Could you help me?
I suggest you try a PivotTable:
Suppose column A contains the dates, and column B the values. I've allowed 6 rows in each; extend as necessary.
Consider a sample date in $D$1. The formulas you need are:
MIN: =MIN(IF(D1=A1:A6,B1:B6,MAX(B1:B6))). (You need to enter this as an array formula).
MAX: =MAX(IF(D1=A1:A6,B1:B6,MIN(B1:B6))). (You need to enter this as an array formula).
Use AVERAGEIF out of the box.
Remember that you need to press Ctrl + Shift + Return to enter an array formula. Then it's a simple case of copying that formula downwards.
They return the minimum or maximum value of the entire sample if a given date is not present in the set, which might not be desirable. You could adjust this behaviour with a containing IF.
You can take care of the pseudo-MIN/MAX with the AGGREGATE¹ function using the 14 (LARGE) and 15 (SMALL) sub-functions together with the 6 (ignore errors) option and the AVERAGEIF function can take care of the rest.
      
The standard formulas in F2:H2 are,
=AGGREGATE(15, 6, ($A$2:$A$60000)/($C$2:$C$60000=$E2), 1)
=AGGREGATE(14, 6, ($A$2:$A$60000)/($C$2:$C$60000=$E2), 1)
=AVERAGEIF($C$2:$C$60000, $E2, $A$2:$A$60000)
Fill down as necessary. An advantage of this method is that you can get the second, third, etc smallest or largest simply by raising the 1 (k ordinal) number at the right end of the AGGREGATE formula.
¹ The AGGREGATE function was introduced with Excel 2010. It is not available in earlier versions.

Create a formula that returns a minimum date from a range based on cell values in another column

I am looking for a formula that will return the earliest date from a column, based on the contents of values in other cells. (Actually I want a Min and Max date, but am assuming the Max will be identical to any Min solution )I know I can return the date I want just by using MIN and specifying the range of cells I want, but I ideally want the formula to be dynamic. I have looked around and believe I possibly need to use a combination of index and match, but cant find any examples that use Min and Max. I have considered using dynamic named ranges to define my task groups, but that would mean having to define a static number of task groups, and there could be many task groups.
The sheet below shos some sample date on the left of the workbook, with the summary data on the right. The "hidden worker column" was an idea I had that I though might make the solution easier. So I want the summary data on the right to use either column A, or column B if its easier, to display the min and max dates based on the section number in column F - Is this possible without VBA?
#mthierer's link is good. If you wanted to remove the need to add a "helper column", you could try (data in A1:C10; summary table in E1:G2):
{=MIN(IF(ROUNDDOWN($A$1:$A$10, 0)=$E1, $B$1:$B$10))} (or {=MAX(...)} with $C$1:$C$10)
Note that you have to enter the formula as an array formula with CtrlShiftEnter.
Data (A1:C10):
1 23 57
1.1 42 91
1.2 35 100
1.3 39 80
1.4 28 51
1.5 30 96
2 33 52
2.1 11 73
2.2 48 80
2.3 16 59
Summary Results (E1:G2):
1 23 100
2 11 80

Using SUMIF and having a function in sum_range

I have a column like:
156
2105 Kb
15 Kb
163
14 secs
65 Kb
etc
What I want to do is to put a function at the bottom of that column, and have it sum the numbers where the unit is Kb (so 2105 + 15 + 65 = answer). I got as far as:
=sumif(right(C200:C201,2),"Kb",LEFT(C200:C201,FIND(" ",C200:C201)-1))
Which fails for numerous reasons I think. I am guessing the sum_range in the SUMIF can not be a function. Happy to move away from SUM and IF if there is another solution.
The problem is that SUMIF cannot take processed ranges as the 'sum_column'. You could use SUM and IF separately in an array function:
=SUM(IF(RIGHT(C200:C201,3)=" Kb",LEFT(C200:C201,FIND(" ",C200:C201)-1)*1,0))
Array function means that after typing the formula in, you will need to press Ctrl+Shift+Enter for it to work.

Extracting the upper quartile data from an array and placing it in new column

Hi and thanks for any help with this in advance
Below is a hypothetical data set; abundance = count data; mud% = the mud content in which the animals were found; mud bin = bins i've made up depending on the mud%; and UQ = upper quartile of the abundance data from its corresponding mud bin (i.e. the upper quartile for the abundance data in mud bin 1 is 17.25 etc).
Problem:
In excel, for abundance data in each of the four mud bins, I'm wanting to extract any values in the abundance column that are >= the upper quartile value for that particular mud bin and place these in a new column on the same sheet (with no gaps between rows from values that didn't meet the criteria) along with their corresponding mud% value in the neighboring cell. I've added the new columns to the below sheet to give you an idea of what I'm after.
abundance | mud% | mud bin | UQ | | New column | Mud% |
18 10.9 1 18 10.9(mud bid 1)
15 6.5 1 44 38.9(mud bin 1)
6 13.4 1 45 38 (mud bin 2)
13 42.1 1 37 37.8(mud bin 2)
15 36.4 1 etc
44 38.9 1 17.25 etc
22 46 2
30 36.4 2
45 38 2
29 35.3 2
37 37.8 2
29 41.8 2 35.25
11 44.4 3
17 47.8 3
21 40.7 3
15 13.9 3
35 13.9 3
14 13.9 3
15 13.9 3 19
19 12 4
14 12 4
10 12 4
12 12 4
14 12 4
13 12 4
45 9.525 4
66 9.525 4
78 9.525 4 45
The reality is I have a rather large dataset containing abundance data for a number of species, all on the same excel sheet and would greatly appreciate any insight into how I might achieve this in the most efficient manor.
For starters, to make this explanation simpler, I will assume that the last row of data is in row 100.
Populate Upper Quartile values for all line items
First you'll need to use the Quartile formula; however, since you want to find the upper quartile within a bin, you'll have to use an array formula. Put this formula in your UQ column (place in cell D2 and drag down). When entering the formula Be sure to press Ctrl+Shift before pressing Enter
=QUARTILE(IF($C$2:$C$100=C2,$A$2:$A$100,""),3)
The first part of this formula, $C$2:$C$100=C2 is your condition. Everywhere this condition is met, you will get the corresponding value in $A$2:$A$100; otherwise, you'll get a blank value. This will give you an array of abundance values that matches the indicated mudbin, C2. now that you have your subset of data, the quartile function will give you the value in the 3rd quartile (17.25 for mudbin 1, which will be placed next to every row that has a mudbin of 1).
Now that we have all the quartiles, we can get all the abundance values that are greater than the UQ for that mudbin. This is done in two parts
Get abundance values greater than mudbin UQ
First, you need to select one column of cells that has the same number of rows as your data (for example, select cells F2:F100)
Enter the following formula into the formula bar (while F2:F100 are highlighted) and press Ctrl+Shift, then enter
=IF($A$2:$A$100>$D$2:$D$100,$A$2:$A$100,"")
Similar to the IF statement used before, this formula finds all the abundance values that are greater than their corresponding UQ value. Now column F will have an abundance number where it is greater than it's UQ value, and a blank where it is not. Now onto the final step.
Populate abundance values that are greater than the UQ value, without the blanks
Select G2:G100 (your "New Column" in your sample data)
Enter the following formula into the formula bar (while G2:G100 are highlighted) and press Ctrl+Shift, then enter
=INDEX(F2:F100,SMALL(IF(F2:F100<>"",ROW(F2:F100)-1),ROW()-ROW($F$1)))
Looking at the IF statement again, this will find every value in F2:F100 that is not blank, but instead of grabbing the values, we'll keep track of the row number of that non blank value (done by ROW(F2:F100)-1
). Now that we have the row numbers of all the non blank values, we can grab the non-blank values in order and populate them in G2:G100. ROW()-ROW($F$1) is a counter, and SMALL will use the counter to determine the nth smallest number to return. Once we have our row number of the non blank value, INDEX returns that value
Finally, to populate the Mud%, you'll need to use the row number of the non blank values to get the mud% and the mud bin (You have the formula already to get the row number of the non blank value).
It's not a simple answer, but at least you won't have to use VBA.

Resources