How to create Count if and average formula together - excel-formula

For example:
count if cell d12,d16,d20,d24 are greater then zero
take that number and then divide it by
d12,d16,d20,d24 to get the average of those four cells, even if one or more cells have zero in them.
This has to be done to get weekly and monthly average headcount.

Maybe:
=(D12+D16+D20+D24)/(1*(D12>0)+1*(D16>0)+1*(D20>0)+1*(D24>0))

Related

Excel: SUMPRODUCT with percentages

I use the following formula to calculate the SUMPRODUCT of the values in a column with the condition that there is a match between B2:B6 and A1:A3 (shoutout to user:8162520).
=SUMPRODUCT(($B$1:$B$6=$A$9)*(G2:G6))
Now however I would like to subtract to that result the percentage in C1 and/or D1, and "give it" to one of the other blue numbers, again with the condition that there is a match between C2:C6 or D2:D6 and A7:A9.
So for example in G7 the result for "1" should be 50% of 10 + 75% of 5, because "2" takes 50% of 10(G2) and "3" takes 25% of 5(G5).
The point is to create an overview of how many hours employees (1,2,3) have to spend spend on project B2:B6 for each week (E,F,G), and what happens if other employees take a certain percentage of the workload (C,D). What is the most efficient way to do this?
The numbers in A, B,C, D are reference numbers, they should not be part of the calculation. Maybe it's clearer if I use letters. See also the right results for E7:G7. The outcome must be the sum of the values in each column (workload) minus the percentage in C and D IF there is someone sharing the workload:
So deducting the percentage in C1:D1, presumably where there is no workload the result should be zero?
=SUMPRODUCT(($B$2:$B$6=$A7)*($C$2:$D$6<>"")*(1-$C$1:$D$1)*G$2:G$6)

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.

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 calculate the daywise average and multiply it to number of rows in that particular day

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.

How to achieve equal Sum Values horizontally and vertically in Excel

I'm working on this for a week now and still could not get the result I want. What I want is to have an equal result between the horizontal total and vertical total when summing up every columns in excel. Please consider this worksheet.
Every TSalary values in each row is equal to each values in its row in Gross Pay Columns. The same thing also in TDeductions with the columns in Deductions. However, after summing up each row and getting its overall total in AD13 & AE13, I am not getting the same value with the total when summing up every columns in gross pay and deductions.
In column AE you seem to have rounded each value to the nearer cent. In cell N13 you have summed the unrounded values.
The 4 half-cents (in column N) that have thus been rounded to a full cent cause your total to be 2 cents higher than the total of the unrounded amounts.
You need to be consistent when applying roundings if you wish your totals to be consistent.

Resources