Excel average values in time step - excel

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.

Related

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.

Pivot table cannot find difference between January current year to December of previous year. Excel 2010

I am weeks into making my first ever pivot tables, cant believe the power of them but have hit a snag I cannot overcome.
I have a worksheet which has a column with raw data (manually imputed)
Then I have another 2 columns that calculate the difference from the previous month and the % difference. This works fine.
As you can see January 2015 is blank as the difference field is looking for the previous month and January is the first month.
how can I get it to understand to look at December 2014
When there are two different levels of grouping, i.e. Year and Month, it is not possible to get Excel to compare the last item of one group with the first item of the previous group.
Excel treats the additional level of grouping as a different field, which is visible when looking at the PivotTable fields. The Years of the Date show as a separate field:
When choosing to calculate the difference, Excel can only compare to values within the same field. Note that you can compare to a specific month value, but not a specific month of a specific year:
Similarly, Excel can't compare to values from the previous grouping, even though human-logic knows it's the previous value in the overall sequence.
To see the difference between each month across years, it's necessary to have all Year-Months in a single field. This isn't possible using PivotTable grouping on normal dates.
The workaround requires a new field to be added to the data which contains a single value per Year-Month. The PivotTable will then naturally group the data by these Year-Month values.
There are two ways this can be achieved:
Calculate the first day of each Year-Month
Insert another column with this formula (referring to a date in the A2 cell):
=Date(Year(A2),Month(A2),1)
This performs the grouping before the data goes into the PivotTable by treating every date as the first of the month. In the PivotTable, the full date will appear by default. You can apply Custom Number Formatting to the field to display only the Month and Year, for example: "mmm yyyy"
This is a better solution when grouping by months as it allows more formatting options.
Calculate a text value for each Year-Month
Insert a column with this formula:
=TEXT(A2,"yyyy mm")
For example, the following data:
Can generate this PivotTable (with sums and then differences):
The text solution has the drawback that you must specify the Year and then Month numerically (and padded to 4 and 2 digits respectively) if you want the PivotTable to automatically order the values in chronological order.
The benefit of the text solution is greater flexibility. For example, you could group bi-monthly with more advanced formulas or group two fields of actual data together by concatenation.
Have you tried combining the month and year in one cell? So on the source data, in the month column have:
Aug-14
Sep-14
Oct-14
Nov-14
Dec-14
Jan-15
Instead of having one column for month name and one for year.
Make sure that once you input the months in your raw data tab, they go to the right side of the cell meaning that Excel sees them as dates not text.

Average each hour's meter readings

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.

Generate trend graph in excel

I encountered a practical problem that can be simplified as follows:
My excel sheet has a single column which is the date I had a beer can. It can repeat based on the number of beers cans I had a day. (eg. I had three beers on 5/9/2012) I need to generate the trend of my beer consumption per week. How can I do it in excel?
**Date of beer**
5/9/2012
5/9/2012
5/9/2012
5/12/2012
...
7/3/2012
You could make a pivot table. Date as a row field, Count of Date (i.e., count of beers) as a data field. Group the row field Date by 7 days to get weekly totals.
You'd probably be better off with a two column spreadsheet. Column A = Date; Column B = Number of cans. Then you could easily just make a line graph from that.
If you already have a large amount of data in your format you can use excel's subtotal function to create the two column format for you.
First i would put a formula in to get a week number for each date, and then use a count if for each week of the year.
This formula will assign each day of the year the week number of the year it falls in. Put this in each cell next to your dates.
=IFERROR(1+INT((AF12-DATE(YEAR(AF12+4-WEEKDAY(AF12+6)),1,5)+WEEKDAY(DATE(YEAR(AF12+4-WEEKDAY(AF12+6)),1,3)))/7),0)
Once that is done create a column of numbers 1-52 (53 for leap year) and do
=countif(rangeofcalcdweeknumbers,week1to52)
and copy that down for all 52 or 53 weeks
Then make a graph based on the final two columns

Resources