How to calculate the daywise average and multiply it to number of rows in that particular day - excel

I have daywise excel data of four months which contains hourly data from 10 AM to 3 PM or sometimes 10 AM to 2 PM....1PM ..... like wise it is varying. The column A contains the date, Column B contains the time and column C and D has the data which i want to average for each day and multiply it to the number of occurrence.
For example If I have a data in column C and D for 17 Oct from 10 AM to 3PM (6 Hours)..Then i want to average these hourly data for a day and multiply it by 6. Since my interval of hourly data is not fixed, that is why i want a code which can average the daywise data and multiply it to the number of occurrence. I want to average the data 1 and data 2 for each day and to multiply its average by the number of occurrence of data in that particular day

I could not exactly get what does "average these hourly data" means since Average basically means summing all data within a day and dividing them to the occurrences. If you again multiply by the number of daily occurrence, you will get the summed value again.
Apart from above unclear point, un-merging all column B cells and filling all your rows with date data will be very helpful in order to form a quick sum or average formula based on the date conditions.
After doing above step, you may enter the below formula to E2 to get the sum of Col:C, for all data dated A2; 17-Oct.
=SUMIFS(C:C,A:A,A2)
And you may get the occurences on the date of your row data, you should use the formula and copy down:
=COUNTIFS(A:A,A2)
In combination of above 2 formulas, you may calculate the averages and/or date occurrences. I may write an exact solution if you may enter your requested values into COL:E and provide a screenshot.

Related

Calculate maximum of a subrange in a table based on multiple conditions

I want to calculate the maximum amount of rain fallen on a day.
Column B contains the date as YYYYMMDD (value, not text)
Column C contains the number of the hour of measurement (ranging from 1 until 24)
Column N contains the amount of rain fallen in [mm] : 0 if no rain; positive integer if rain has fallen
What formula calculates the maximum amount of rain fallen on a day?
So:
for january 4th I want to sum N2:N25
for january 5th I want to sum N26:N49
etc.
and return the maximum of those calculated values
REMARK:
a value of -1 in column N indicates 'not measured' and shoudl be treated as 'no rain' (= 0)
I found one, my testing area only extended 1,000 rows, but it should scale nicely.
=MAX(SUMIFS(N2:N1000,B2:B1000,B2:B1000))
Remember to enter as an array formula by confirming with CNTRL + SHIFT + ENTER
Here's an ugly solution that takes 3 cells, but is much faster than my first formula:
=MAX(SUMIF(N2:N25,">"&0),SUMIF(N26:N49,">"&0),SUMIF(N50:N73,">"&0),SUMIF(N74:N97,">"&0),SUMIF(N98:N121,">"&0),SUMIF(N122:N145,">"&0),SUMIF(N146:N169,">"&0),SUMIF(N170:N193,">"&0),SUMIF(N194:N217,">"&0),SUMIF(N218:N241,">"&0),SUMIF(N242:N265,">"&0),SUMIF(N266:N289,">"&0),SUMIF(N290:N313,">"&0),SUMIF(N314:N337,">"&0),SUMIF(N338:N361,">"&0),SUMIF(N362:N385,">"&0),SUMIF(N386:N409,">"&0),SUMIF(N410:N433,">"&0),SUMIF(N434:N457,">"&0),SUMIF(N458:N481,">"&0),SUMIF(N482:N505,">"&0),SUMIF(N506:N529,">"&0),SUMIF(N530:N553,">"&0),SUMIF(N554:N577,">"&0),SUMIF(N578:N601,">"&0),SUMIF(N602:N625,">"&0),SUMIF(N626:N649,">"&0),SUMIF(N650:N673,">"&0),SUMIF(N674:N697,">"&0),SUMIF(N698:N721,">"&0),SUMIF(N722:N745,">"&0),SUMIF(N746:N769,">"&0),SUMIF(N770:N793,">"&0),SUMIF(N794:N817,">"&0),SUMIF(N818:N841,">"&0),SUMIF(N842:N865,">"&0),SUMIF(N866:N889,">"&0),SUMIF(N890:N913,">"&0),SUMIF(N914:N937,">"&0),SUMIF(N938:N961,">"&0),SUMIF(N962:N985,">"&0),SUMIF(N986:N1009,">"&0),SUMIF(N1010:N1033,">"&0),SUMIF(N1034:N1057,">"&0),SUMIF(N1058:N1081,">"&0),SUMIF(N1082:N1105,">"&0),SUMIF(N1106:N1129,">"&0),SUMIF(N1130:N1153,">"&0),SUMIF(N1154:N1177,">"&0),SUMIF(N1178:N1201,">"&0),SUMIF(N1202:N1225,">"&0),SUMIF(N1226:N1249,">"&0),SUMIF(N1250:N1273,">"&0),SUMIF(N1274:N1297,">"&0),SUMIF(N1298:N1321,">"&0),SUMIF(N1322:N1345,">"&0),SUMIF(N1346:N1369,">"&0),SUMIF(N1370:N1393,">"&0),SUMIF(N1394:N1417,">"&0),SUMIF(N1418:N1441,">"&0),SUMIF(N1442:N1465,">"&0),SUMIF(N1466:N1489,">"&0),SUMIF(N1490:N1513,">"&0),SUMIF(N1514:N1537,">"&0),SUMIF(N1538:N1561,">"&0),SUMIF(N1562:N1585,">"&0),SUMIF(N1586:N1609,">"&0),SUMIF(N1610:N1633,">"&0),SUMIF(N1634:N1657,">"&0),SUMIF(N1658:N1681,">"&0),SUMIF(N1682:N1705,">"&0),SUMIF(N1706:N1729,">"&0),SUMIF(N1730:N1753,">"&0),SUMIF(N1754:N1777,">"&0),SUMIF(N1778:N1801,">"&0),SUMIF(N1802:N1825,">"&0),SUMIF(N1826:N1849,">"&0),SUMIF(N1850:N1873,">"&0),SUMIF(N1874:N1897,">"&0),SUMIF(N1898:N1921,">"&0),SUMIF(N1922:N1945,">"&0),SUMIF(N1946:N1969,">"&0),SUMIF(N1970:N1993,">"&0),SUMIF(N1994:N2017,">"&0),SUMIF(N2018:N2041,">"&0),SUMIF(N2042:N2065,">"&0),SUMIF(N2066:N2089,">"&0),SUMIF(N2090:N2113,">"&0),SUMIF(N2114:N2137,">"&0),SUMIF(N2138:N2161,">"&0),SUMIF(N2162:N2185,">"&0),SUMIF(N2186:N2209,">"&0),SUMIF(N2210:N2233,">"&0),SUMIF(N2234:N2257,">"&0),SUMIF(N2258:N2281,">"&0),SUMIF(N2282:N2305,">"&0),SUMIF(N2306:N2329,">"&0),SUMIF(N2330:N2353,">"&0),SUMIF(N2354:N2377,">"&0),SUMIF(N2378:N2401,">"&0),SUMIF(N2402:N2425,">"&0),SUMIF(N2426:N2449,">"&0),SUMIF(N2450:N2473,">"&0),SUMIF(N2474:N2497,">"&0),SUMIF(N2498:N2521,">"&0),SUMIF(N2522:N2545,">"&0),SUMIF(N2546:N2569,">"&0),SUMIF(N2570:N2593,">"&0),SUMIF(N2594:N2617,">"&0),SUMIF(N2618:N2641,">"&0),SUMIF(N2642:N2665,">"&0),SUMIF(N2666:N2689,">"&0),SUMIF(N2690:N2713,">"&0),SUMIF(N2714:N2737,">"&0),SUMIF(N2738:N2761,">"&0),SUMIF(N2762:N2785,">"&0),SUMIF(N2786:N2809,">"&0),SUMIF(N2810:N2833,">"&0),SUMIF(N2834:N2857,">"&0),SUMIF(N2858:N2881,">"&0),SUMIF(N2882:N2905,">"&0),SUMIF(N2906:N2929,">"&0),SUMIF(N2930:N2953,">"&0),SUMIF(N2954:N2977,">"&0),SUMIF(N2978:N3001,">"&0),SUMIF(N3002:N3025,">"&0),SUMIF(N3026:N3049,">"&0),SUMIF(N3050:N3073,">"&0),SUMIF(N3074:N3097,">"&0),SUMIF(N3098:N3121,">"&0),SUMIF(N3122:N3145,">"&0),SUMIF(N3146:N3169,">"&0),SUMIF(N3170:N3193,">"&0),SUMIF(N3194:N3217,">"&0),SUMIF(N3218:N3241,">"&0),SUMIF(N3242:N3265,">"&0),SUMIF(N3266:N3289,">"&0),SUMIF(N3290:N3313,">"&0),SUMIF(N3314:N3337,">"&0),SUMIF(N3338:N3361,">"&0),SUMIF(N3362:N3385,">"&0),SUMIF(N3386:N3409,">"&0),SUMIF(N3410:N3433,">"&0),SUMIF(N3434:N3457,">"&0),SUMIF(N3458:N3481,">"&0),SUMIF(N3482:N3505,">"&0),SUMIF(N3506:N3529,">"&0),SUMIF(N3530:N3553,">"&0),SUMIF(N3554:N3577,">"&0),SUMIF(N3578:N3601,">"&0),SUMIF(N3602:N3625,">"&0),SUMIF(N3626:N3649,">"&0),SUMIF(N3650:N3673,">"&0),SUMIF(N3674:N3697,">"&0),SUMIF(N3698:N3721,">"&0),SUMIF(N3722:N3745,">"&0),SUMIF(N3746:N3769,">"&0),SUMIF(N3770:N3793,">"&0),SUMIF(N3794:N3817,">"&0),SUMIF(N3818:N3841,">"&0),SUMIF(N3842:N3865,">"&0),SUMIF(N3866:N3889,">"&0),SUMIF(N3890:N3913,">"&0),SUMIF(N3914:N3937,">"&0),SUMIF(N3938:N3961,">"&0),SUMIF(N3962:N3985,">"&0),SUMIF(N3986:N4009,">"&0),SUMIF(N4010:N4033,">"&0),SUMIF(N4034:N4057,">"&0),SUMIF(N4058:N4081,">"&0),SUMIF(N4082:N4105,">"&0),SUMIF(N4106:N4129,">"&0),SUMIF(N4130:N4153,">"&0),SUMIF(N4154:N4177,">"&0),SUMIF(N4178:N4201,">"&0),SUMIF(N4202:N4225,">"&0),SUMIF(N4226:N4249,">"&0),SUMIF(N4250:N4273,">"&0),SUMIF(N4274:N4297,">"&0),SUMIF(N4298:N4321,">"&0),SUMIF(N4322:N4345,">"&0),SUMIF(N4346:N4369,">"&0),SUMIF(N4370:N4393,">"&0),SUMIF(N4394:N4417,">"&0),SUMIF(N4418:N4441,">"&0),SUMIF(N4442:N4465,">"&0),SUMIF(N4466:N4489,">"&0),SUMIF(N4490:N4513,">"&0),SUMIF(N4514:N4537,">"&0),SUMIF(N4538:N4561,">"&0),SUMIF(N4562:N4585,">"&0),SUMIF(N4586:N4609,">"&0),SUMIF(N4610:N4633,">"&0),SUMIF(N4634:N4657,">"&0),SUMIF(N4658:N4681,">"&0),SUMIF(N4682:N4705,">"&0),SUMIF(N4706:N4729,">"&0),SUMIF(N4730:N4753,">"&0),SUMIF(N4754:N4777,">"&0),SUMIF(N4778:N4801,">"&0),SUMIF(N4802:N4825,">"&0),SUMIF(N4826:N4849,">"&0),SUMIF(N4850:N4873,">"&0),SUMIF(N4874:N4897,">"&0),SUMIF(N4898:N4921,">"&0),SUMIF(N4922:N4945,">"&0),SUMIF(N4946:N4969,">"&0),SUMIF(N4970:N4993,">"&0),SUMIF(N4994:N5017,">"&0),SUMIF(N5018:N5041,">"&0),SUMIF(N5042:N5065,">"&0),SUMIF(N5066:N5089,">"&0),SUMIF(N5090:N5113,">"&0),SUMIF(N5114:N5137,">"&0),SUMIF(N5138:N5161,">"&0),SUMIF(N5162:N5185,">"&0),SUMIF(N5186:N5209,">"&0),SUMIF(N5210:N5233,">"&0),SUMIF(N5234:N5257,">"&0))
And in a separate cell
=MAX(SUMIF(N5258:N5281,">"&0),SUMIF(N5282:N5305,">"&0),SUMIF(N5306:N5329,">"&0),SUMIF(N5330:N5353,">"&0),SUMIF(N5354:N5377,">"&0),SUMIF(N5378:N5401,">"&0),SUMIF(N5402:N5425,">"&0),SUMIF(N5426:N5449,">"&0),SUMIF(N5450:N5473,">"&0),SUMIF(N5474:N5497,">"&0),SUMIF(N5498:N5521,">"&0),SUMIF(N5522:N5545,">"&0),SUMIF(N5546:N5569,">"&0),SUMIF(N5570:N5593,">"&0),SUMIF(N5594:N5617,">"&0),SUMIF(N5618:N5641,">"&0),SUMIF(N5642:N5665,">"&0),SUMIF(N5666:N5689,">"&0),SUMIF(N5690:N5713,">"&0),SUMIF(N5714:N5737,">"&0),SUMIF(N5738:N5761,">"&0),SUMIF(N5762:N5785,">"&0),SUMIF(N5786:N5809,">"&0),SUMIF(N5810:N5833,">"&0),SUMIF(N5834:N5857,">"&0),SUMIF(N5858:N5881,">"&0),SUMIF(N5882:N5905,">"&0),SUMIF(N5906:N5929,">"&0),SUMIF(N5930:N5953,">"&0),SUMIF(N5954:N5977,">"&0),SUMIF(N5978:N6001,">"&0),SUMIF(N6002:N6025,">"&0),SUMIF(N6026:N6049,">"&0),SUMIF(N6050:N6073,">"&0),SUMIF(N6074:N6097,">"&0),SUMIF(N6098:N6121,">"&0),SUMIF(N6122:N6145,">"&0),SUMIF(N6146:N6169,">"&0),SUMIF(N6170:N6193,">"&0),SUMIF(N6194:N6217,">"&0),SUMIF(N6218:N6241,">"&0),SUMIF(N6242:N6265,">"&0),SUMIF(N6266:N6289,">"&0),SUMIF(N6290:N6313,">"&0),SUMIF(N6314:N6337,">"&0),SUMIF(N6338:N6361,">"&0),SUMIF(N6362:N6385,">"&0),SUMIF(N6386:N6409,">"&0),SUMIF(N6410:N6433,">"&0),SUMIF(N6434:N6457,">"&0),SUMIF(N6458:N6481,">"&0),SUMIF(N6482:N6505,">"&0),SUMIF(N6506:N6529,">"&0),SUMIF(N6530:N6553,">"&0),SUMIF(N6554:N6577,">"&0),SUMIF(N6578:N6601,">"&0),SUMIF(N6602:N6625,">"&0),SUMIF(N6626:N6649,">"&0),SUMIF(N6650:N6673,">"&0),SUMIF(N6674:N6697,">"&0),SUMIF(N6698:N6721,">"&0),SUMIF(N6722:N6745,">"&0),SUMIF(N6746:N6769,">"&0),SUMIF(N6770:N6793,">"&0),SUMIF(N6794:N6817,">"&0),SUMIF(N6818:N6841,">"&0),SUMIF(N6842:N6865,">"&0),SUMIF(N6866:N6889,">"&0),SUMIF(N6890:N6913,">"&0),SUMIF(N6914:N6937,">"&0),SUMIF(N6938:N6961,">"&0),SUMIF(N6962:N6985,">"&0),SUMIF(N6986:N7009,">"&0),SUMIF(N7010:N7033,">"&0),SUMIF(N7034:N7057,">"&0),SUMIF(N7058:N7081,">"&0),SUMIF(N7082:N7105,">"&0),SUMIF(N7106:N7129,">"&0),SUMIF(N7130:N7153,">"&0),SUMIF(N7154:N7177,">"&0),SUMIF(N7178:N7201,">"&0),SUMIF(N7202:N7225,">"&0),SUMIF(N7226:N7249,">"&0),SUMIF(N7250:N7273,">"&0),SUMIF(N7274:N7297,">"&0),SUMIF(N7298:N7321,">"&0),SUMIF(N7322:N7345,">"&0),SUMIF(N7346:N7369,">"&0),SUMIF(N7370:N7393,">"&0),SUMIF(N7394:N7417,">"&0),SUMIF(N7418:N7441,">"&0),SUMIF(N7442:N7465,">"&0),SUMIF(N7466:N7489,">"&0),SUMIF(N7490:N7513,">"&0),SUMIF(N7514:N7537,">"&0),SUMIF(N7538:N7561,">"&0),SUMIF(N7562:N7585,">"&0),SUMIF(N7586:N7609,">"&0),SUMIF(N7610:N7633,">"&0),SUMIF(N7634:N7657,">"&0),SUMIF(N7658:N7681,">"&0),SUMIF(N7682:N7705,">"&0),SUMIF(N7706:N7729,">"&0),SUMIF(N7730:N7753,">"&0),SUMIF(N7754:N7777,">"&0),SUMIF(N7778:N7801,">"&0),SUMIF(N7802:N7825,">"&0),SUMIF(N7826:N7849,">"&0),SUMIF(N7850:N7873,">"&0),SUMIF(N7874:N7897,">"&0),SUMIF(N7898:N7921,">"&0),SUMIF(N7922:N7945,">"&0),SUMIF(N7946:N7969,">"&0),SUMIF(N7970:N7993,">"&0),SUMIF(N7994:N8017,">"&0),SUMIF(N8018:N8041,">"&0),SUMIF(N8042:N8065,">"&0),SUMIF(N8066:N8089,">"&0),SUMIF(N8090:N8113,">"&0),SUMIF(N8114:N8137,">"&0),SUMIF(N8138:N8161,">"&0),SUMIF(N8162:N8185,">"&0),SUMIF(N8186:N8209,">"&0),SUMIF(N8210:N8233,">"&0),SUMIF(N8234:N8257,">"&0),SUMIF(N8258:N8281,">"&0),SUMIF(N8282:N8305,">"&0),SUMIF(N8306:N8329,">"&0),SUMIF(N8330:N8353,">"&0),SUMIF(N8354:N8377,">"&0),SUMIF(N8378:N8401,">"&0),SUMIF(N8402:N8425,">"&0),SUMIF(N8426:N8449,">"&0),SUMIF(N8450:N8473,">"&0),SUMIF(N8474:N8497,">"&0),SUMIF(N8498:N8521,">"&0),SUMIF(N8522:N8545,">"&0),SUMIF(N8546:N8569,">"&0),SUMIF(N8570:N8593,">"&0),SUMIF(N8594:N8617,">"&0),SUMIF(N8618:N8641,">"&0),SUMIF(N8642:N8665,">"&0),SUMIF(N8666:N8689,">"&0),SUMIF(N8690:N8713,">"&0),SUMIF(N8714:N8737,">"&0),SUMIF(N8738:N8761,">"&0),SUMIF(N8762:N8785,">"&0))
The Max() of these two cells is the total for the year. It's brute force but it solves the speed issue.

How to calculate moving average 7 days of milk production of a each cow, Dates not sorted. Excel

The daily milk production of each cow is recorded daily. I would like to cancel out the noise. Therefore I would like to use a moving average of seven days ( 3 days before and 3 days after, including current date production) in Excel.
The data is not ordered according to date therefore offset function cannot be used.
Additional Information: "Date" is in Column A, Cow No in Column B and Milk in Column C . Rows are from 1-22.
The expected result would be get get a moving average of milk for 7 days of each cow ( -3 days before <=current date and < days+3 days after current date from each cow.
Similiar function used to calculate rolling average of past year is =AVERAGEIFS(B2:K2,B1:K1,">"&TODAY()-365,B1:K1,"<"&TODAY()). A similiar formula could be used.
Problem when using sumproduct formula: No Data for 7 days should be 0 7D Average. However is given 1.79 .Rolling AVerage with the Sumproduct formula Problem
You can try to use a combination of SUMPRODUCT and AVERAGE functions. Note that this is an array formula, so you need to enter it using Ctrl+Shift+Enter keys:
=SUMPRODUCT(AVERAGE(IF(($B$2:$B$22=B2)*($A$2:$A$22>=(A2-3))*($A$2:$A$22<=(A2+3)),$C$2:$C$22)))
Result:
The average for the first three entries (D2:D4) is exactly the same as the value in column C, as there are no other dates provided for the range between 23-29 January. The remaining values (D5:D22) should properly present the 7-day average values.
This may not be the pretiest solution but it works. We can use countifs in the following way:
1. Create a column that combines Cow no and Date (I called it CowNoDate) with the format CowNo + "-" + date(as number). I put it in column C.
2. Sort list by this new column
3. use the following formula in column E to calculate the running average:
=SUMIFS(D:D,C:C,">="&B2&"-"&(A2-3),C:C,"<="&B2&"-"&(A2+3))

Find row when Cumulative sum reaches certain value with condition

I have a table with 3 columns Date, Item and Number. Each row indicates how many items of each Item was received on that date. I am trying to find the date on which cumulative sum reaches 100 or more in that month. Each month will have a target for each item which will be saved in another sheet but for simplicity we can assume that its a fixed number of 100.
Example Data:
Date Item Number
1/2/2018 A 10
2/2/2018 B 10
2/2/2018 A 15
5/2/2018 C 25
6/2/2018 A 50
7/2/2018 B 10
7/2/2018 C 10
8/2/2018 A 25
9/2/2018 A 20
I am looking for the formula which should act on the data similar to above and give the result as 8/2/2018 which is the date on which the cumulative sum for Item A reached 100.
Each month will have different target number, and will have different number of entries.
I have tried using SUMIF and adding a additional column etc but this data is just part of a big data and each item limit is saved in a different sheet etc which is not easy to merge. Thanks in advance for help.
In Excel only, you can use Offset to develop an array of items and numbers containing 1,2,3...9 rows and then SUMIF to add each of them up. Then use Match to find the first one =100 and Index to find the matching date (in F2):
=INDEX(A2:A10,MATCH(100,SUMIF(OFFSET(B2,0,0,TRANSPOSE(ROW(A2:A10))-ROW(A1)),"A",OFFSET(C2,0,0,TRANSPOSE(ROW(A2:A10))-ROW(A1))),0))
Must be entered as an array formula using CtrlShiftEnter.
EDIT
To find the first sum which is >=100 (in G2):
=INDEX(A2:A10,MATCH(TRUE,SUMIF(OFFSET(B2,0,0,TRANSPOSE(ROW(A2:A10))-ROW(A1)),"A",OFFSET(C2,0,0,TRANSPOSE(ROW(A2:A10))-ROW(A1)))>=100,0))
Sum which reaches exactly 100
Sum which does not reach exactly 100 (the number in row 9 has been changed to 24):

sum assigned vlaues if sum for each value meets a specific criterion

in excel, I have two columns. one containing months of the year (in numbers) each month number occurring in different number of rows, and in the second column I have a duration of time for each row (in hours and minutes).
now I want to do the following job with an excel function in just one cell (the same job could be done using a table with 12 cells, each for one month but I want to pack it all in one cell):
1- for each month number, sum all cells in the second column (time) which have that month number in the adjacent cell (this could be done with a sumif )
2- if that sum is more than 4 hours then return one for that month else return zero (this step could be done with a formula like this: IF(R10>(--"4:00");1;"") )
3. in the end the numbers assigned to each month summed together.
thanks to everyone who helps
the picture below, shows the steps:
enter image description here
Try,
=SUM(--(SUMIFS(Table1[time],Table1[month],{1,2,3,4,5,6,7,8,9,10,11,12})>TIME(4,0,0)))

how to get cumulative amount of columns under certain criteria when skipping some of them

I have a question with regards to getting the cumulative amount of some columns when skipping others (please see the picture).
Lets say on a certain row we have certain type of op units for which we have 3 columns for every month (Revenue, COS, G&A). We have this for Jan, Feb, March and then 3 columns to total the amounts for quarter 1. The next 3 columns are for April.
My question is how to make formulas that can add the cumulative amount for year to date in each category while skipping the Q1 amounts. I can do with offset but I can't skip Q1 column.
You need a SUMIFS formulas that sum amounts in columns B:P for each category but exclude amounts where B1:P1 = "q1". So for YTD Revenue the formula would be:
=SUMIFS($B$3:$P$3,$B$2:$P$2,Q$2,$B$1:$P$1,"<>q1")
Copy to the right into columns R:S and then down rows as required.
Sorry, I don't think that offset /sumif will work because of 3 different criteria.
Otherwise the month I will be selecting in row 1 after end of the table (after Dec17 and Q4) there will be 3 foxed columns that will show YTD cumulative figure which should change when the month changes

Resources