help using OFFSET within IF

Special K

Board Regular
Joined
Jun 20, 2011
Messages
83
Office Version
  1. 2010
Platform
  1. Windows
I am calculating a conditional MEDIAN of column C based on the value of column A. The following works:

Excel Formula:
{=MEDIAN(IF(A2:A60=4770,C2:C60))}

But when I generalize the formula to include all rows except the first using OFFSET, I get a #VALUE! error:

Excel Formula:
{=MEDIAN(IF(OFFSET(A2,0,0,ROWS(A:A)-ROW(A2)+1)=4770,OFFSET(C2,0,0,ROWS(C:C)-ROW(C2)+1)))}

Am I not using OFFSET correctly? The OFFSET formulas don't return errors when I input them individually into cells.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
I am not a fan of OFFSET because of it's volatility, but that probably is not an issue with your formulas. But, Using INDEX to build references may work for you:

Mr excel questions 68.xlsm
ABCDEF
1
28107138911195311953
368046420
447705793
519524577
650745996
71150817770
847704106
9126392776
10166561378
1195434618
12477016855
13477015788
141749816823
15144601476
16477018923
17175303190
18190359742
19734217483
201541717617
21477011953
22188511829
231226812003
2447704404
2547707514
2647707747
27542417390
2847701300
29597419475
30477013477
31477013616
32477015539
33848218371
341038417067
351786218703
36155347841
371117913438
38161795121
391912717868
4077042004
416086849
421996014335
4312296921
441825311347
45480614046
461591212999
47574012563
48558419587
4940329287
5068838481
51109743609
52180981946
531922616522
54100663241
55168124437
56125511018
5758719085
58497619653
59699919302
6083075836
61
Sheet2
Cell Formulas
RangeFormula
E2E2=MEDIAN(IF(A2:A60=4770,C2:C60))
F2F2=MEDIAN(IF(INDEX(A:A,2,1):INDEX(A:A,ROWS(A:A),1)=4770, INDEX(C:C,2,1):INDEX(C:C,ROWS(C:C),1)))
 
Upvote 0
... Am I not using OFFSET correctly?..
You are using OFFSET correctly; however, it does not like having the ROW() function in the formula.

You can try using a work-around -- for example, CSE
Excel Formula:
=MEDIAN(IF(OFFSET(A2,0,0,X1)=4770,OFFSET(C2,0,0,X1)))
where cell X1 contains =ROWS(A:A)-ROW(A2)+1,

Or just switch to the INDEX-based solution offered by awoohaw.
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

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