Average each hour's meter readings - excel

I have two columns of data with five or six meter readings each hour:
time (HH:MM:SS) (C3:C103) meter readings (D3:D103).
I would like to average each hour's readings to condense the data down to one averaged meter reading per hour.
I tried =Averageif(C3:C103,Hour=10,D3:D103) but clearly have something wrong.

Assuming you have just time values in C3:C103 (not with dates) then you could get your results like this:
List the numbers 0 to 23 in F2 down then use this formula in G2 copied down
=AVERAGEIFS(D$3:D$103,C$3:C$103,">="&F2/24,C$3:C$103,"<"&(F2+1)/24)
That will give you a table with the results for each hour

You can do this with one formula.
The following is an Array formula (need to press Ctrl + Shift + Enter, instead of just Enter to add it), and works for anything in the 10 o'clock hour.
{=AVERAGE(IF(HOUR(C3:C55)=10,D3:D55))}
Again, type the formula without the curly brackets then hold down Ctrl + Shift then press Enter
Basically the formula looks at the hour of each entry, checks to see if it is 10, then averages the adjacent numbers if the previous condition is true.
ALTERNATIVE:
You don't need a formula at all, (or any helper columns) if you just use a pivot table.
Select your data
Add your time column to the Row Labels section of the pivot table
add your meter readings column to the values section
In the Pivot table right-click on the meter readings data and select Show Values As ... Average in the menu.
In the pivot table, right-click on the time data and select the group option. In the option box select Hours only, and click OK.
That will give you the average for each hour without any additional formulas. It's also nice because it requires little maintenance after you have created, other than refreshing each time you get new data.

solution for my comment earlier:
This is easily done with a pivot table. First, break down the HH:MM:SS column down into an hours column only (since you want it grouped by hours). Then put all of the data into a pivot table, and put the 'hours' column in the row labels, and the meter readings (make sure to do an average, not a count) in the values field. This should be what you need.

Related

excel sumproduct formula calculating time

hello dear forum members and admins,
i created a dashboard to calculate customer numbers based on raw data prepared on day and time set.
there is no problem here I can calculate. but I also want to calculate the monthly average customer numbers based on the time set. for this purpose, I created a data table in a daily_pax_sheet. for e.g in January between 10:00 - 10:30 CUSTOMERS E totally number is 35 and this 35 amount occurred in 8 days, then it calculates 4 amounts. in daily_pax_details sheet row 107 formula firstly calculate sum of the data then it divides the day number (for e.g this amount occurs in 8 days) but in some cases, raw data include more than 20k line and it's calculating and waiting too much. is there any other way to do it in a quick way ? how can I change this formula to make calculation quick ?
https://docs.google.com/spreadsheets/d/1y-2Ke2ssskzSM-wYszU54CIEraPbEX4X/edit#gid=459027650
UPDATE: thanks for the idea and solution from members
I also realized another solution and I think it will help other people in the future. we can get the data to the pivot table with counting the unique values with changing field settings. To do it you should get the data pivot table with selecting "add this data to the data model". then changing value field settings with the "Distinct value". hope it will help another pppl.
Your SUMIFS formulas use whole columns as criteria, so every calculation checks more than 1 million cells. And because you use more than 1 column, then every time you update *anything in the file, Excel checks more than 4 million cells because of your formulas...
I changed all to use the righ rawdata range of cells used, not whole columns. And now it works perfect.
As example, your formula is:
=SUMIFS('raw data'!$R:$R;'raw data'!$D:$D;'Daily customer'!C$3;'raw data'!$I:$I;'Daily customer'!$A4)
And I changed to:
=SUMIFS('raw data'!$R$2:$R$2461;'raw data'!$D$2:$D$2461;'Daily customer'!C$3;'raw data'!$I$2:$I$2461;'Daily customer'!$A4)
Because in your sheet raw data your data goes from row 2 to 2461, so in every calculation Excel checks only 2460 cells, not 1 million....
Change all your formulas like this and you should notice a better performance indeed.
UPDATE: I've uploaded the modified file: https://docs.google.com/spreadsheets/d/11isonBHFJTFFWtZTJg66JHbtyrD0XFGl/edit?usp=sharing&ouid=114417674018837700466&rtpof=true&sd=true
It works smoothly for me. No lag or anything. I can change any cell value, move the graph, filter cells and everything is done almost instantly.

Excel : MAX number in any 30 day period

I`m trying to work out a formula, on how to get the MAX amount, for any 30 day consumption period, for a certain item, when all the criteria are in one data table. See picture below. Date is in column A.
I have table with a formula where I copy and paste data manually
=SUM(IF([Date]>[#Date]-30,IF([Date]<=[#Date],[Amount])))
At the end- I would like to have the list of all the item numbers in one column and the one next to it should have - max amount used in any 30 day period.
In my Master file I have around 1300 Item numbers, which is time-consuming to get the MAX data on-by-one.
Can anyone help?
Instead of copy and paste, you can do a pivot table on the data in the first screenshot. Use the dates in rows, use the Amount in values. If you want to do this for item numbers, use them in rows before the date.
You should then have a nice table with dates and amounts per date, no duplicate dates.
If you don't want to use pivot tables, create the date column manually, without duplicates, and use a Sumifs formula to sum the data from the original sheet. Enter the start date, then use the fill handle and drag down. That will automatically increment the date. Let's say the dates are in column A, first row has labels, then use in B2 and copy down:
=sumifs('the other sheet'!H:H,'the other sheet'!A:A,A2)
Next, in C2 you can use a MAXIFS function along the lines of
=MAXIFS(B:B,A:A,"<="&A2-30)

Excel - Take Average of Monthly Data

I have a historical data set for commodity pricing. Throughout the data set, the data starts inputting prices on specific days, rather than the average of the entire month. In order to keep the flow of having only the average pricing for the months.
In the best case scenario, I would use an Averageif function, however, the data for each month doesn't display a consistent amount of days.
How can I automate this the process: If the month is the same as the previous row and different than the next row, calculate the average of the ^ rows until you hit the next month.
Here's a simple display of what I mean:
]1
You can use a pivot table to get the output you want. It will also be neatly organized instead of having your averages mixed in with a mostly blank column. Photo below shows the set-up/output of a pivot table generated with random data.
For a solution without pivot tables, you can use the following formula :
=AVERAGEIFS($B$1:$B$30;$A$1:$A$30;">="&(A1-DAY(A1)+1);$A$1:$A$30;"<="&EOMONTH(A1;0))
The above example is from cell C1, and can be copied down the entire list. The dates are in $A$1:$A$30 and the values in $B$1:$B$30. The first conditions test on the first day of the month (calculated as A1-DAY(A1)+1),and the second condition as last day of the month (calculated as EOMONTH(A1;0)
This will obviously put the average value of the month on each row, but will also work if your data is not sorted on date. If this is the case, and you only want to display one number per month in the column (as in your own example), you can add an additional IF statement wrapped around the formula:
=IF(EOMONTH(A2;0)=EOMONTH(A1;0);"";AVERAGEIFS($B$1:$B$30;$A$1:$A$30;">="&(A1-DAY(A1)+1);$A$1:$A$30;"<="&EOMONTH(A1;0)))
So it will display empty in all cells, except where the month changes.

Excel average values in time step

I have a problem with analyzing data measurement in Excel. Here is my issue.
In column A input is time (day.month hour), in column B it is day in year. From column C to I are numbers from measurement analyzer.
As you can see from the Excel Prnt Scrn, in single day we measured values in different time. I have to calculate average of all values (from value 1 to value 7) for specific day.
Example: average of values in Time 1.1.2012 (average values 1.1.2012 at 0:59, 1:59, 2:59 ….).
The problem is that I have more than 9000 rows with different time steps. I tried with Filter function, but I only manage to get time from older to newest!
Appreciate for any useful advice.
First, assign a value for all cells in the Day column using the Date number type. You will need to use Find and Replace to change all the "." to "/" in your Time column for this to work (i.e. DD.MM.YY HH:MM becomes DD/MM/YY HH:MM). Copy the Time column into the Day column. Highlight the Day column, right click, and select Format Cells. Change the format to Date, and it will cut off the time values. If you want a number for Julian Day and not the date, insert a new column and see this article for calculating day of the year: http://inanecoding.co.uk/2012/10/converting-excel-date-to-julian-day-of-year-number/
Second, use the Subtotal function under the Data tab to average each day's values. The this will work with date or Julian Day (or any column containing more than one unique value). This will change the appearance of the sheet but all the base data will still be there. However, for convenience of switching between raw and averaged data, I'd make a copy of the sheet before proceeding. Click Subtotal and in the dropdown menu "For each change in:" select which column (Date or Day) you want to use as a grouping. For the "Use function" menu, select Average. Below, check the columns you want to find averages for (Value 1-7). Click okay.
Since you have 9000 records, this may take a few seconds. Play around with the 1,2,3 boxes in the upper left corner to see the level of detail you want in the resulting spreadsheet.

Getting average of data with multiple entries for a single date using pivot table in Excel

I have tried this, but I am unsuccessful. I have the data dump in an excel sheet (Excel 2010). The first column has month. The second has the dates. The third column has numerical data. I have applied filters on each column to get the data on the Pivot Table. There are entries for each date. There are sometimes multiple entries for a single date. Now, when I run the Pivot, I get the proper sum, but when I select average, the average is accurate only for the single entries associated with a date. I need to calculate average of multiple data entries for a single date. Here is an example:
November 11/1/13 30
November 11/2/13 25
November 11/3/13 20
November 11/3/13 25
Now, when I run the Pivot table and select to average the data, it calculates the average as (30+25+20+25)/4 = 20 (since there are 4 entries, so the sum gets divided by 4).
This is not desirable.
I require the calculation to be made as taking the 3rd and 4th entry as one for the date 11/3/13. So, the required output is (30+25+(20+25))/3 = 33.33.
I hope the example gives an clear idea of the requirement. I need a solution for this. How do we modify the Pivot so that the average is calculated not based on just the number of entries, but the average is calculated for the number of days.
Create the pivot table described by Ron (with Sum only, not Average), then copy & paste special (values) this pivot table, then pivot that for averages.
Put your dates in the "Row Labels" area. It will Sum and Average by Date
Edit: To get the average of the sum of the daily values, you can either enter an Average formula someplace for the Pivot Table Sum Column, or you could use the following array-entered formula:
=SUM(Values)/SUM(1/COUNTIF(Dates,Dates))
Where Dates is the range where you have your list of Dates (on the original data sheet) and Values is the range where you have your original list of Values.
To array-enter a formula, after entering
the formula into the cell or formula bar, hold down
while hitting . If you did this
correctly, Excel will place braces {...} around the formula.
SUM(1/COUNTIF(Dates,Dates)) will return a count of the Unique dates, so it will return 3 for the dates in question in your example.
This proposed solution uses a working column named: Value (U)
Assuming that your data is located at [B4:B8].
Add a working column at [E4:E8]
Enter this formula at [E5:E8]:
= IF( COUNTIF($C$5:$C5,$C5) > 1, 0,
SUMIF($C$5:$C$8,$C5,$D$5:$D$8) )
Then use the working column Value (U) to sum and average the values, also add Value (U) as Page Field to filter out the Value (U)=0.

Resources