Excel - Find max value in a 2D array with logic - excel

I'm trying to find the maximum value from the 15 minute interval data that has dates associated with each row seen below:
DATE UOM 00:01-00:15 kW 00:16-00:30 kW 00:31-00:45 kW 00:46-01:00 kW
7/1/2010 KW 907.2 892.8 883.2 883.2
7/2/2010 KW 907.2 849.6 859.2 825.6
7/3/2010 KW 811.2 806.4 806.4 801.6
7/4/2010 KW 763.2 768 758.4 772.8
This data is electrical demands for my school's campus, and I'm trying to find peak, partial peak, and off peak maximum demands. There are approximately 4 years of data with each row consisting of a single data.
Peak hours occur during 12:00 - 18:00 hours
Partial Peak occurs during 08:31 - 11:59 & 18:00 21:30
Off Peak occurs during 21:30 - 08:30
I'd like to be able to get those values for each month of each year. But so far the logic isn't coming to me, and everything I'm looking up just shows me index-match tutorials. Any help would be greatly appreciated.

Simply use MAX or a combination of two MAX functions in order to determine maximums for any given timespan.
In my screenshot, you can see how the ranges are defined by the columns. Therefore you may have to adjust the ranges to correspond to your actual spreadsheet.
For example, for cell CW1 it uses the formula =MAX($AY2:$BV2). This determines the value of the maximum value for all 15-minute time spans within that range. Because 12:01 occurs in column AY, and 18:00 ends in column BV, it's possible to find the maximum between 12:01 - 18:00 by using the MAX function.
For time spans that are not continuous, we can split them into multiple ranges. For CX and CY we do this by using two MAX functions. So a maximum value is retrieved for each continuous time span, and then the outer MAX determines the maximum of the two local maximums.
Therefore, for CX:
=MAX(MAX($AK2:$AX2),MAX($BW2:$CJ2))
For CY:
=MAX(MAX($C2:$AJ2),MAX($CK2:$CT2))
Note that I don't have your full data set, so these values are garbage.

Related

Is there an excel function calculate future value of constant payments at variable interest rate

Known that:
FV function: future value of constant payments at constant interest rate
FVschedule function: future value of no payments at variable compound interest
My task is to calculate the future value of constant payments at variable interest rate.
Say the principal is 10,000. Annual rate is 5%. Tenor with 2 monthly period starting at Jan. The periodic payment in arrear is 1,300.
Interest for Jan is calculated as (10,000 * 5% * 31 / 360 = 43) The principal repaid is (1,300 - 43) = 1,257.
Interest for Feb is calculated as ((10,000-1,257) * 5% * 28 / 360 = 34) The principal repaid is (1,300 - 34) = 1,266.
The future value (aka balloon payment) would be 10,000 - 1,257 - 1,266 = 7,477.
So I would like to know if there is a formula could calculate 7,477 by inputting the above data, rather than calculate the whole repayment schedule each time.
Thank you for your help.
I do not think there is such a function. There is however a way how to approach this in an excel-like manner. As you correctly anticipated, excel is just the right tool for that, as it can re-calculate the whole repayment schedule each time, many times a second.
First, collect the parameters like that to the columns K & L
Second, create a table with the schedule. First column label Date and it will be the date of the last days of the months. Lets assume that you start with the first day of the current month, so the first row will be
=EOMONTH($L$6;[#Period])
where $L$6 is the cell with start date. The next column [#Period] has just the count of the schedule periods, i.e. 1,2,3,4... as many as you like. You can use formula
=ROW()-1
for that.
Next column label Days with formula
=DAY([#Date])
That is for calculating the effective interest rate.
Next column label Aliquote with formula
=[#Days]/$L$2
with the effective interest rate for the current period (month).
Now it gets interesting. The next columns label B/O for the beggining of month outstanding amount
=$L$4-SUM(G$1:G1)
and copy/past for the next rows. It calculates the outstanding amount based on the principal parameter stored in L4 by subtracting the sum of Amortizations in the column G we create next.
Next column is then labeled interest
=$L$3*[#Aliquote]*[#[B/O]]
where L3 refers the parameter with the nominal interest rate.
and the next column is labeled Amortization
=$L$5-[#Interest]
calculated from the periodic arrears stored in L5.
The last column is labeled C/O for the close of the month outstanding amount.
=[#[B/O]]-[#Amortization]
If you have done it correctly, it shows you the C/O values running towards zero and then of course negative in the 8th period onward. You can change the parameters to get adjust it for the scenario you need.

Function for finding duration where wave height <3m where time is between 5:00am and 6:00PM

I am trying to find duration for time where wave height is under 3m and time period is between 5:00am and 6:00pm. Trying to find this duration for a month of tidal data.
I have raw data for wave height and timestamps when it is high and low.
eg.
Timestamp Wave_Height
1/01/2022 3:16 0.68
1/01/2022 9:37 6.62
1/01/2022 16:14 1.07
1/01/2022 21:54 5.37
2/01/2022 4:06 0.59
etc…
So far I have got linear interpolation to find points where wave height=3. I am struggling to get a function to find the durations for my limits on time.
Included a picture to explain
Graph of wave data over time
The timestamps occur over different days in the month so difference between times must consider the changed dates in some cases(see rev 2 errors ####### where errors occur for changing of dates)
rev 2 error
The following should work. I have added some columns to avoid complicated formulas.
interpolate when the wave_height = 3 (column G)
add column H which is True when wave_height increases and False if it decreases (at the time in column G):
so cell H6 = F7<3 gives TRUE
add column E to limit the time window to 5:00-18:00.
E7 is =IF(D7<$G$2;$G$2;IF(D7>$H$2;$H$2;D7))
Added column I to calculate the time during wich wave_height < 3. The sum of that column is what you need.
I8 is =H8*(G8-E7)+NOT(H8)*(D8-G8)

Find a growth rate that creates values adding to a determined total

I am trying to create a forecast tool that shows a smooth growth rate over a determined number of steps while adding up to a determined value. We have variables tied to certain sales values and want to illustrate different growth patterns. I am looking for a formula that would help us to determine the values of each individual step.
as an example: say we wanted to illustrate 100 units sold, starting with sales of 19 units, over 4 months with an even growth rate we would need to have individual month sales of 19, 23, 27 and 31. We can find these values with a lot of trial and error, but I am hoping that there is a formula that I could use to automatically calculate the values.
We will have a starting value (current or last month sales), a total amount of sales that we want to illustrate, and a period of time that we want to evaluate -- so all I am missing is a way to determine the change needed between individual values.
This basically is a problem in sequences and series. If the starting sales number is a, the difference in sales numbers between consecutive months is d, and the number of months is n, then the total sales is
S = n/2 * [2*a + (n-1) * d]
In your example, a=19, n=4, and S=100, with d unknown. That equation is easy to solve for d, and we get
d = 2 * (S - a * n) / (n * (n - 1))
There are other ways to write that, of course. If you substitute your example values into that expression, you get d=4, so the sales values increase by 4 each month.
For excel you can use this formula:
=IF(D1<>"",(D1-1)*($B$1-$B$2*$B$3)/SUMPRODUCT(ROW($A$1:INDEX(A:A,$B$3-1)))+$B$2,"")
I would recommend using Excel.
This is simply a Y=mX+b equation.
Assuming you want a steady growth rate over a time with x periods you can use this formula to determine the slope of your line (growth rate - designated as 'm'). As long as you have your two data points (starting sales value & ending sales value) you can find 'm' using
m = (y2-y1) / (x2-x1)
That will calculate the slope. Y2 represents your final sales goal. Y1 represents your current sales level. X2 is your number of periods in the period of performance (so how many months are you giving to achieve the goal). X1 = 0 since it represents today which is time period 0.
Once you solve for 'm' this will plug into the formula y=mX+b. Your 'b' in this scenario will always be equal to your current sales level (this represents the y intercept).
Then all you have to do to calculate the new 'Y' which represents the sales level at any period by plugging in any X value you choose. So if you are in the first month, then x=1. If you are in the second month X=2. The 'm' & 'b' stay the same.
See the Excel template below which serves as a rudimentary model. The yellow boxes can be filled in by the user and the white boxes should be left as formulas.

Find a temperature and work out how long it remained >= this temperature

I have an excel sheet with times in one column and temperatures in another. I'm trying to work out a formula that will find a certain temperature and measure how long it remained at that temperature.
11:25:29 AM 69.3°C
11:26:29 AM 69.6°C
11:27:29 AM 69.8°C
11:28:29 AM 70.0°C
11:29:29 AM 70.2°C
11:35:29 AM 70.8°C
11:36:29 AM 70.3°C
11:37:29 AM 69.5°C
11:38:29 AM 68.5°C
11:39:29 AM 67.5°C
12:39:29 PM 66.3°C
1:39:29 PM 52.1°C
2:39:29 PM 12.1°C
3:39:29 PM 5.0°C
In this example, I would like to find when it hit 70.0°C and how long it stayed above 70.0°C.
This is a bit of a tough problem because you might have multiple occasions where you go above 70 degrees. In that case, do you want the total time spent above 70 in the entire dataset, or do you want the total time spent above 70 consecutively? And then, how are you determining which of these potential multiple nonconsecutive periods you are talking about?
That said, you can try this. If column A is your datetime, and column B is your temp reading, specify another cell as your temperature reference value ($D$1 here), and in column C starting in row 2 do this:
=(A2-A1)*IF(B2>=$D$1,1,0)
and then copy that all the way down. What that does is it calculates the time difference between measurements and then if the temperature at that time is greater than your reference, it multiplies it by 1, otherwise it multiplies by 0. Because a date/time in Excel is really just a number, what you get is an interval of a day between measurements in each cell of column C. In other words, .25 = 6 hours.
Now that you have that data in column C, you are free to further parse it. You can use a simple SUM(C:C) formula in a cell, or you can go back and sum up individual ranges. I hope this helps.

Sum of Averages in Excel Pivot Table

I am measuring room utilization (time used/time available) from a data dump. Each row contains the available time for the day and the time used for a particular case.
The image is a simplified version of the data.
If you read the yellow and green highlights (Room 1):
In room 1, there are 200 available minutes on 1/1/2016.
Case 1 took 60 minutes, case 2 took 50 minutes.
There are 500 available minutes on 1/2/2016, and only one case occurred that day, using 350 minutes.
Room 1 utilization = (60 + 50 + 350)/(200 + 500)
The problem with summing the available time is that it double counts the 200 minutes for 1/1/2016, giving: Utilization = (60+50+350)/(200+200+500)
There are hundreds of rows in this data (and there will be multiple data dumps of differing #'s of rows) with multiple cases occurring each day.
I am trying to use a pivot table, but I cannot obtain the 'sum of averages' for a particular room (see image). I am using a macro to pull the numbers out of the grand total column.
Is this possible? Do you see another way to obtain utilization?
(note: there are lots of other columns in the data, like case start, case end, day of week, etc, that are not used in this calculation but are available)
The reason that you're getting 300 for both Average of Available Time columns is because the grand total is a grand total based on the overall average and not a sum of the averages.
Room 1: 200 + 200 + 500 / 3 = 300
Room 2: 300 + 300 + 300 / 3 = 300
I could not comment on the original question, so my solution is based on a few assumptions.
Assumption #1: The data will always be grouped. E.G. All cases in room 1 on a given day will grouped in sequential rows.
Assumption #2: The available time column is a single value for the whole day, there will never be differing available times on the same day.
Solution: Use column E as the Actual Available Time. This column will use a formula to determine if the current row has a unique combination (Date + Room + Available Time) to the previous and if so, the cell will contain that row's available time.
Formula to use in E2:
=IF(AND($A1 = $A2, $B1 = $B2, $C1 = $C2), 0, $C2)
Extend the formula as far down as necessary and then include the new column in your PivotTable data range.
End Result
I created a unique reference by combining columns and then used sumif/countif/countif.
So the formula in column E would be:
=sumif(colB,cellB,ColC)/Countif(colB,cellE)/Countif(colB,cellE)
Doesn't matter if the data is in order or not then.
Extend the formula as far down as necessary and then include the new column in your PivotTable data range.
The easiest method I would recommend is this.
=SUM(H:H)-GETPIVOTDATA("Average of Available Time",$G$3)
The first term sums the H column, and the second term subtracts the grand total value. It is a dynamic solution, and will change to fit the size of the pivot table.
My assumptions are that the Pivot Table was originally placed in cell G3.

Resources