Round fractional numbers for AVERAGEIF whole number Criteria

loudnoiseman

Board Regular
Joined
Dec 31, 2004
Messages
218
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

My AVERAGEIF range contains fractional numbers but my criteria is whole numbers and I think I need to somehow adapt with a rounding function I suppose so I can get correct average range figures. I'm not sure if pasting this example will work but this illustrates how the fractional numbers are being ignored.

Thanks!

Fractional numbersTo AverageCriteriaAVERAGEIF ignores fractional numbersformula
1​
10​
110AVERAGEIF(A2:A22,E2,B2:B22)
1.2​
100​
2500AVERAGEIF(A2:A22,E3,B2:B22)
1.4​
200​
31000AVERAGEIF(A2:A22,E4,B2:B22)
1.6​
300​
41500AVERAGEIF(A2:A22,E5,B2:B22)
1.8​
400​
52000AVERAGEIF(A2:A22,E6,B2:B22)
2​
500​
2.2​
600​
2.4​
700​
2.6​
800​
2.8​
900​
3​
1000​
3.2​
1100​
3.4​
1200​
3.6​
1300​
3.8​
1400​
4​
1500​
4.2​
1600​
4.4​
1700​
4.6​
1800​
4.8​
1900​
5​
2000​
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi Loudnoiseman,

AVERAGEIF parameters are range,criteria,average_range so your statement in F2 is saying "Look at A2 to A22 and only if it is equal to E2 (the value 1) then average values in B2 to B22".

Only one value in column A is a 1 so it returns the value in that row of B. Same for criteria 2,3,4 and 5.

Please state what you want to be averaged.
 
Upvote 0
How about
Excel Formula:
=AVERAGEIFS(B:B,A:A,">="&E2,A:A,"<"&E2+1)
 
Upvote 0
Solution
Hi Toadstool,

In the first formula, criteria is 1 so yes it's looking for exactly 1 in A:A whereas I'm hoping to modify the formula to round to the nearest whole number in A:A so that 1.2 and 1.4 are also considered 1 and 1.6 and 1.8 are considered 2 thus including associated B:B in the average. I believe the correct answer for criteria 1 is 103.3333333.

I get that I could achieve this with helper columns but my dataset is already almost 400 columns and want to avoid doubling and tripling if I can avoid it.

Hi Fluff,

I'm getting an error with your suggestion but thanks anyway!
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Also what error do you get?
 
Upvote 0
Hi Fluff,

Thanks, I just updated details, I'm using 365 on Windows. The error I got was #DIV/0!

But I do apologize as I copied this post data back into Excel and it's incorrectly formatted as text and not numbers thus the error.

Now I re-created as numbers and I see your formula does work after all and it's rounding down so all 1.x = 1 and 2.x = 2 etc which works for my purposes so indeed thank you very much!!

Loudnoiseman
 
Upvote 0
Yes, actually I prefer to round to the closest whole number so 1.6 would be treated as 2.

Thanks!!
 
Upvote 0
Ok how about
+Fluff 1.xlsm
ABCDEF
1Fractional numbersTo AverageCriteriaAVERAGEIF ignores fractional numbers
21101103.3333333
31.21002500
41.420031000
51.630041500
61.840051900
72500
82.2600
92.4700
102.6800
112.8900
1231000
133.21100
143.41200
153.61300
163.81400
1741500
184.21600
194.41700
204.61800
214.81900
2252000
23
Main
Cell Formulas
RangeFormula
F2:F6F2=AVERAGE(FILTER($B$2:$B$22,ROUND($A$2:$A$22,0)=E2))
 
Upvote 0

Forum statistics

Threads
1,214,817
Messages
6,121,720
Members
449,050
Latest member
MiguekHeka

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top