Automate MIN and MAX temperatures for a certain date - excel

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.

Related

Excel - Find row with conditional statement in XLOOKUP

I'm trying to use XLOOKUP to find a value based on user inputs.
The table looks like this:
Type Start End 33 36 42 48
---------------------------------------
4002 1 7 1.17 1.34 1.5 1.84
4002 8 12 1.84 1.67 2.1 3.45
User selects type, number (can be between start and end), and 33-48
I can nest an XLOOKUP to specify the 3 criteria
=XLOOKUP(*type* & *number* , *typeRange* & *numberRange* ,XLOOKUP(*33-48* , *33-48Range* , *ResultRange* ))
And I can find if a value is between the columns
=IF(AND(*number*>=*Start*,*number*<=*End*),TRUE,FALSE)
Can I combine the two? The data is redundant for numbers 1-7, and I would like to keep the table small.
You sort-of can combine them. I have added a couple of extra rows to the table to see what would happen if you had different Type values as well as number values. The problem then is that if you used approximate match and put in a number like thirteen which is out of range, you might end up getting the next row of the table which would be incorrect. One way round it would be to use the options in Xlookup to search for next-smaller-item in the Start column and next-larger-item in the End column and see if the results match:
=IF(XLOOKUP(I2&TEXT(J2,"00"),A2:A7&TEXT(B2:B7,"00"),XLOOKUP(K2,D1:G1,D2:G7),,-1)=XLOOKUP(I2&TEXT(J2,"00"),A2:A7&TEXT(C2:C7,"00"),
XLOOKUP(K2,D1:G1,D2:G7),,1),XLOOKUP(I2&TEXT(J2,"00"),A2:A7&TEXT(C2:C7,"00"),XLOOKUP(K2,D1:G1,D2:G7),,1),"Error")
If you have some checks in place which make it impossible for number to be out of range, then you can simplify the formula:
=XLOOKUP(I2&TEXT(J2,"00"),A2:A7&TEXT(B2:B7,"00"),XLOOKUP(K2,D1:G1,D2:G7),,-1)
or
=XLOOKUP(I2&TEXT(J2,"00"),A2:A7&TEXT(C2:C7,"00"),XLOOKUP(K2,D1:G1,D2:G7),,1)

Excel - Count of entries below cumulative threshold without helper column

I have the following little table. I'd like a formula that finds the number of values where the cumulative total (of column B) is less than some threshold (tx).
I tried
{=MIN((SUM(OFFSET(B1,0,0,A1:A17))>tx)*A1:A17)-1}
but OFFSET doesn't seem to be arrayable like that. Obviously, this would be trivial with a helper column, but for certain reasons that is not possible.
So the correct answer here should be 10.
tx = .8
A B
1 0.112106465
2 0.110981698
3 0.091959216
4 0.082163441
5 0.073292066
6 0.072407529
7 0.071646289
8 0.061646797
9 0.06011448
10 0.057566381
11 0.050341978
12 0.048227061
13 0.043207335
14 0.03940462
15 0.012914194
16 0.007603446
17 0.004417003
You're not really looking for a MIN; rather it should be MAX that follows your condition.
In E7 as a standard (non-array) formula,
=AGGREGATE(14, 6, ROW(1:17)/(SUBTOTAL(9, OFFSET(B1, 0, 0, ROW(1:17), 1))<D7), 1)
      
I prefer the following array formula** due to its non-volatility:
=MATCH(TRUE,MMULT(0+(ROW(B1:B17)>=TRANSPOSE(ROW(B1:B17))),B1:B17)>=0.8,0)-1
Regards
The most succinct way to do it I've found is
=SUM(--(SUBTOTAL(9,OFFSET(B1,,,A1:A17))<0.8))
entered as an array formula, or, equivalently,
=SUMPRODUCT(--(SUBTOTAL(9,OFFSET(B1,,,A1:A17))<0.8))

Finding the max and average difference

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

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.

Resources