Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ISODD() is odd

Status
Not open for further replies.

N1GHTEYES

Technical User
Jun 18, 2004
771
GB
I recently used an array formula in a workbook where I wanted to find the mean of all the values in the range "data" which lay on the odd-numbered rows.

The formula I used was:
={average(IF(ISODD(ROW(data)),data))}
This gave a VALUE! error.

However,
={average(IF(ROW(data)=ODD(ROW(data)),data))}
worked fine.

Any idea why?

Tony
 



hi,

Try it WITHOUT array key seq
[tt]
=AVERAGE(IF(ISODD(ROW()),data))
[/tt]

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 


sorry, the original formula as an array seems to work for me
[tt]
={AVERAGE(IF(ISODD(ROW(data)),data))}
[/tt]


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
If you do that then it returns one of two possible outcomes (I tried it):

If data starts on an odd row, it gives the average of the whole of data, otherwise it returns zero. I think that is because in the expression:
=AVERAGE(IF(ISODD(ROW(data)),data))
when it is entered without being an array formula, one check only is done on ISODD(ROW(data)) and what it returns is whether the first row of data is odd or not.

Tony
 
Sorry Skip, we seem to have overlapped. My response was to your first post.

In response to your second post, I really do get the #VALUE! error. Could this be an office-version-dependent issue? I am using 2003, SP3. How about you?

Tony
 
In office 2003 the ISODD formula is non-standard and is not suited for use in an array-formula. In 2007 I believe it has been made part of the standard and can be used in array-formulae.

Cheers,

Rofeu
 
Oh, that would explain it then. It's nice to know I'm not just being stupid.

For info, if anyone else has issues with it, note that you can do what I mentioned in my first post, i.e. replace (ISODD(range)) with (range=ODD(range)). That does work in array formulae.

Tony
 
If you're in 2003 and (like many of us who lack brain-cells) don't feel you understand array formulae, there are several other options.

My favourite: assuming the data are in column A,
B1=A1
B2=A2
B3=A3+B1
Copy formula in B3 to the end of the data.
The last two entries in column B are the sums of all odd and even rows, and can be divided by an appropriately rounded count of total rows (round up) to find the mean.

This approach has one useful feature: you can easily modify it to average every 3rd, 7th or 13th row if you so wish.

 
Thanks Lionel. I could use a "helper column" as you suggest, and it would have the benefit of being flexible wrt the base (i.e. not just 2 bu 3, 4 or any number I want), but I really wanted to avoid putting enything into the sheet which did not need to be there.

I am pulling in user-selected data from some data files and was trying to extract all of the information I required by means of suitable array formulae, partly to keep the spreadsheet as simple and uncluttered as possible, but mostly for speed.

I think I've more or less got my head around array formulae, but was puzzled as to why this one did not work. The answer seems to be what Rofeu suggested, i.e. the ISODD function simply does not support array formulae.

Tony
 
If you want to use an array-formula and be flexible wrt the base you can use (MOD(COLUMN(<ref>)+<offset>,<ColDif>)=0) instead of ROW(data)=ODD(ROW(data)), where <ColDif> is the number of columns per which you want to check and <offset> the column you want with respect to the base, where <offset> is smaller then <ColDif>.

(obviously you can use it for rows by replacing the COLUMN for ROW)

Cheers,

Rofeu
 
Also true and a nice thought. I'll bear it in mind for when I need to use it. For now just Odd & Even rows will do for me.

BTW, I know the ISEVEN() function also does not support array formulae - do you know of any more? Is there a list anywhere?

Tony
 


Are you stating, without reservation, that ISEVEN() is odd too??? ;-)

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
ISEVEN() is only odd when it says zero which oddly enough is not even odd or even...

OK, enough of this odd behavior

[Blue]Blue[/Blue] [Dragon]

If I wasn't Blue, I would just be a Dragon...
 
Am I in Making an Impression or Microsoft Office?
[spineyes]

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 



Maybe your are Making an Impression IN Microsoft Office. [glasses]


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top