How to make a "trending" or "averaging" curve - excel

I have a spreadsheet on which I've been tracking my weight for the last year.
I weigh myself nearly every day, and I can be off by as much as 5 pounds from day to day.
I would like make a graph shows the overall pattern of my weight loss / gain, but without all of the noise.
What are some formulas that I can use to calculate the overall trend?

Place the raw daily measurements in A1 thru A365In B2 enter:
=(A1+A2+A3)/3
and copy down. Column B will give you a smoother dataset for plotting and trending.

Once you have enough data points a "moving average" will help reduce the daily noise. Let's say you have 10 data points starting in A1:
120.0 119.0 114.1 116.7 112.0 108.7 107.9 104.6 108.9 111.7
In cell C2 you could use the formula AVERAGE(A1:C1) and copy it to the end of your data set. THe relative references will always average the last 3 measurements.
Now your data looks like:
120.0 119.0 114.1 116.7 112.0 108.7 107.9 104.6 108.9 111.7
117.7 116.6 114.3 112.5 109.5 107.1 107.1 108.4
So your second row has far less variation that the raw data.
You can also get fancy and make the number of measurements variable. If that number were stored in A5 (below your data) then the formula would be something like
=AVERAGE(OFFSET(C1,0,0,1,-MIN(COLUMN(),$A$5)))
The MIN ensures that you don't go past the beginning of the data set (if you do a 5-day moving average you can;t go back 5 days from the 4th day, etc.)

Related

I came across this question and the answers. I'm having similar challenge but i tried the answer to non-365 office users but could not get it

this data set below. It has 3 columns (PTQ, % Growth, $ Growth) that all need ranked individually then summed up and then ranked again for a total power rank of each region. Is there any way I can do this with a single formula? I do this a lot and it would be nice not to have to rank everything individually each time.
To clarify, I do not want to rank first on one column then another, they all need to be ranked equally together.
Data:
Region
PTQ
% Growth
$ Growth
TR ARIZONA
103
17.5
201330
TR IDAHO UTAH
75.5
-6.3
-69976
TR LA HAWAII
99.4
19.2
194840
TR LA NORTH
125
32.7
241231
TR NORTHERN CALIFORNIA
102.3
26.2
308824
TR NORTHWEST
91.1
-0.6
-4801
TR SAN FRANSISCO
76.9
-16.7
-158387
TR SOUTHERN CALIFORNIA
106.9
30.8
495722
TR TUCSON
100.3
7.6
34888
Assuming the same layout as P.b., in I4:
=1+SUMPRODUCT(N(MMULT(CHOOSE({1,2,3},RANK(C$4:C$12,C$4:C$12),RANK(D$4:D$12,D$4:D$12),RANK(E$4:E$12,E$4:E$12)),{1;1;1})<SUM(RANK(C4,C$4:C$12),RANK(D4,D$4:D$12),RANK(E4,E$4:E$12))))
and copied down.
This is quite challenging in older Excel, but possible nonetheless:
=IFERROR(
INDEX(
MMULT(--(RANK($C$4:$C$12,$C$4:$C$12)+RANK($D$4:$D$12,$D$4:$D$12)+RANK($E$4:$E$12,$E$4:$E$12)>=TRANSPOSE(RANK($C$4:$C$12,$C$4:$C$12)+RANK($D$4:$D$12,$D$4:$D$12)+RANK($E$4:$E$12,$E$4:$E$12))),ROW($C$4:$C$12)^0),ROW($A1))
-SUMPRODUCT(--(MMULT(--(RANK($C$4:$C$12,$C$4:$C$12)+RANK($D$4:$D$12,$D$4:$D$12)+RANK($E$4:$E$12,$E$4:$E$12)>=TRANSPOSE(RANK($C$4:$C$12,$C$4:$C$12)+RANK($D$4:$D$12,$D$4:$D$12)+RANK($E$4:$E$12,$E$4:$E$12))),ROW($C$4:$C$12)^0)
=INDEX(MMULT(--(RANK($C$4:$C$12,$C$4:$C$12)+RANK($D$4:$D$12,$D$4:$D$12)+RANK($E$4:$E$12,$E$4:$E$12)>=TRANSPOSE(RANK($C$4:$C$12,$C$4:$C$12)+RANK($D$4:$D$12,$D$4:$D$12)+RANK($E$4:$E$12,$E$4:$E$12))),ROW($C$4:$C$12)^0),
ROW($A1))))+1
,"")
(requires being entered with ctrl+shift+enter)
Explanation:
First an array is made of the sum of the 3 rankings:
RANK($C$4:$C$12,$C$4:$C$12)+RANK($D$4:$D$12,$D$4:$D$12)+RANK($E$4:$E$12,$E$4:$E$12)
This results in your so called Rank Sum - array.
Then - since RANK requires a range, not an array, we need an alternative to create a ranking of the array: MMULT can do that.
MMULT(RankSum>=RankSum,ROW(RankSum)^0) creates an array of the ranked RankSum, however. If 2 are ranked equally - for instance rank 1 - it's rank both as 2, not 1. Therefore I used SUMPRODUCT to calculate the number of items in the calculated MMULT-array that equal the indexed MMULT-array result as an alternative to COUNTIF, which is also limited to take a Range, not Array. So MMULTarray-SUMPRODUCT(--(MMULTarray=IndexedMMULTarray)) is your end result.
Calculation is based on your data being in B4:E12 and formula above is entered (with ctrl+shift+enter) in a cell in row 4 and copied down; I4 in the shared screenshot.
Even though this formula answers your question, I doubt this is what you thought what it would be. Changing the range to a different range by itself could be very teasing. And calculating the rankings manually and sum/rank them is probably easier to maintain. You may make it more dynamical by adding INDEX in the ranges.

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)

Filtering discrepancies in duplicate measurements

I have a dataset with the following problem.
Sometimes, a temperature sensor would return duplicate readings at the exact same minute, where sometimes 1 of 2 of the duplicates is "reasonable" and the other is slightly off.
For example:
TEMP TIME
1 24.5 4/1/18 2:00
2 24.7 4/1/18 2:00
3 24.6 4/1/18 2:05
4 28.3 4/1/18 2:05
5 24.3 4/1/18 2:10
6 24.5 4/1/18 2:10
7 26.5 4/1/18 2:15
8 24.4 4/1/18 2:15
9 24.7 4/1/18 2:20
10 22.0 4/1/18 2:20
Line 5, 7 & 10 are readings that are to be removed as they are too high or low (doesn't make sense that within 5 minutes it will rise and drop more than a degree in a relatively stable environment).
The goal at the end with this dataset is to "average" the similar values (such as in line 1 & 2) and just remove the lines that are too extreme (such as line 5 & 7) from the dataset entirely.
Currently my idea to formulate this is to look at a previously obtained row, and if one of the 2 duplicates is +/- 0.5 degree, to mark in a 3rd column with TRUE so I can filter out all the TRUE values in the end. I'm not sure how to communicate within the if statement that I'm looking for a + OR - 0.5 of a previous number however. Does anyone know?
Here is a google sheet example that does what you want:
https://docs.google.com/spreadsheets/d/1Va9RjSeulOfVTd-0b4EM4azbUkYUb22jXNc_EcafUO8/edit?usp=sharing
What I did:
Calculate a column of a 3-item running average of the data using "=AVERAGE(B3:B1)"
Filter the list using "=IF(ABS(B2-C2) < 1, B2, )"
Calculate the average of the filtered list
The use of Absolute Value is what provides "+ OR -" that you were looking for. It is saying if the distance between two numbers is too much, then don't include the term.
So, A Simple Solution came to my mind. Follow the Following steps given below:
Convert Data to Table
Add a 4th column at the last
Enter the formula "Current Value - Previous Value"
Filter the Column with high difference values
Delete those rows of filtered data and you'll be left with Normal Values
Here's the ref. Image
Or If you want to consider the Same time difference only then do the following:
Convert your data to Table
Add 4th column at the end of table
Writhe the Following Formula to 4th Column
IF(Current_Time = Previous_Time, Current_Temp-Previous_Temp,"")
Filter and Delete the Data with high Difference
See the following Image:

Confused by Excel formula

I am an university final year student and I'm working on my research project.
I have to perform simulation by using MS Excel and there's a problem which keep confusing me during this process.
When, I'm doing the simulation, I type the following formula
=IF(B14>16000,"0",IF(B14<200,"1","0"))
what I'm trying to do is " IF B14 (water tank) is smaller than 16000, the pump will turn on, marked as "1", else it will be turned off, marked as "0".
I wanna make the tank be filled up when there's not enough of water inside it.
However, the formula turns out stop the pump once the water tank storage is more than 200.
What I want to achieve, is refill the water tank to almost its full capacity, not stopping it once the capacity is just above 200.
Is there any formula pattern i could be adopted in tis situation?
Thanks you so much,
How about
=IF(B14>16000,0,IF(B14<200,0,1))
So, if the tank is full then "off",
if the tank is not full and less than 200 then off,
otherwise the pump is on.
Based on your response to my comment:
If you have a cell (named Status) that returns 1 or 0 depending on if the pump is currently on or off, then you can use:
=IF(B14<200,1,IF(B14>16000,0,Status))
If you do not have such a cell, you can do this in a single cell by enabling iterative calculations (See Tools/Options/Formulas) and using this formula:
C14: =IF(OR(B14<200,AND(B14<16000,C14=1)),1,0)
^^^ ^^^
Note the cell reference in the formula being the same as the cell in which the formula exists.
My chart looks like this:
B C D E F
1 Tank 1 Pump In Out TimeInterval
2 16200 0 10.6 8.15 10
3 16118.5 0 10.6 8.15 10
4 16037 0 10.6 8.15 10
5 15955.5 0 10.6 8.15 10
Row 2 is the initial state, input the values manually. Formulas I'm using are:
B3=B2-E2*F2+D2*F2*C2
C3=IF(B2<200,1,IF(AND(B2<16000,C2=1),1,0)

selection of data from a data rows

I got wind speed data in excel table like this:
(wind speed) (wind direction)
Year|month|day|00:00|06:00|12:00|18:00||00:00|06:00|12:00|18:00||X|
1966|01|01|5|12|6|8||60|360|270|50||X|
goal is to get in each day wind directin at wich was the max wind speed, for example: in firs jan. 1966 the max wind speed was 12 m/s at 06:00 and directon at the same time was 360. I need that 360 in next (X) column. If there is equal max wind speed in several observaton times then is no mater which of those directions put in at next column.
Is it poseble do it in MS excel? If someone can help me it would be so great!
Assuming the wind speed columns are D-G and the directions H-K then put the following formula in your column where the 'X' is (for row 2; copy it down the other rows)
=LOOKUP(MAX(D2:G2);D2:G2;H2:K2)

Resources