Compare last value in an array with the average of the previous ones

Sparcot

Banned user
Joined
Aug 23, 2016
Messages
50
Hello. Help needed: need a formula to compare the last input value in an array with the average of the previous ones. Example:

| J | F | M | A | M | J | J | A | S | O | N | D | Formula column |
| 2 | 3 | 4 | 1 | 5 | 4 |

In this case the formula should let me know that in June the value was higher than the average of Jan - May [ 4>(2+3+4+1+5)/5 ]. If it's possible the formula to return an index (-1, 0, 1) to apply some conditional formatting in formula column.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
if your data is in a row starting A2 (say A2:L2), select B3 and input the following formula:
=(AVERAGE($A2:A2)>B2)-(AVERAGE($A2:A2)<b2)
<b2)
Copy this formula across to the extent of the data area in row 3

It will return 1 if the previous months' avg is greater than the value for the month of interest, 0 if equal and -1 if less

if your data is in a col starting B1 (say B2:B12, select B3 and input the following formula:
=(AVERAGE(B$1:B1)>B2)-(AVERAGE(B$1:B1)<b2) and="" copy="" down.<="" b2)
</b2)></b2)
</b2)
 
Last edited:
Upvote 0
Please nix the previous reply...there was some error in pasting formulas

if your data is in a row starting A2 (say A2:L2), select B3 and input the following formula:
=(AVERAGE($A2:A2)>B2)-(AVERAGE($A2:A2)>B2)
<b2)<b2)
<b2)
<b2)
Copy this formula across to the extent of the data area in row 3

It will return 1 if the previous months' avg is greater than the value for the month of interest, 0 if equal and -1 if less

if your data is in a col starting B1 (say B2:B12), select C2 and input the following formula:
=(AVERAGE(B$1:B1)>B2)-(AVERAGE(B$1:B1)<B2)
<b2)<b2)
and copy down
</b2)<b2)
</b2)

</b2)
</b2)<b2)
 
Last edited:
Upvote 0
Thanks for the reply, but it's not what I actually need. In a month i will input the value for the next month for example July. And it already should compare July value to Jan - Jun...
 
Upvote 0
I believe this formula will give you the result you asked for...

=SIGN(LOOKUP(9E+99,A2:L2)-(SUM(A2:L2)-LOOKUP(9E+99,A2:L2))/(COUNT(A2:L2)-1))
 
Upvote 0
With ref to column data format, you would use the following formula in the conditional formatting dialog box for cell C2
=IF(ISBLANK(B3),"",(AVERAGE(B$1:B1)>B2)-(AVERAGE(B$1:B1)<b2))'
is less than symbol B2))
<b2))
(gets truncated at less than symbol)
<b2))
<b2))
<b2))
<b2))
and set the format conditions on basis of result of this formula (-1,0,1)
Copy the formula+format of Cell C2 down the data range

Similarly for data on row format</b2))
</b2))
</b2))
</b2))
</b2))></b2))'
 
Last edited:
Upvote 0
I believe this formula will give you the result you asked for...

=SIGN(LOOKUP(9E+99,A2:L2)-(SUM(A2:L2)-LOOKUP(9E+99,A2:L2))/(COUNT(A2:L2)-1))

Actually, I've used a ROUND with 2 digits to eliminate the period after the comma [EX: 3.7-3.6(6)]:

=SIGN(ROUND(LOOKUP(9E+99,A2:L2)-(SUM(A2:L2)-LOOKUP(9E+99,A2:L2))/(COUNT(A2:L2)-1),2))[/QUOTE]
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

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