You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Average of cells to end cell of row which is always growing

I have written a formula that will average the numbers in cells in a row, the problem is that the table is growing on a daily basis

the formula is

AVERAGEIF(F43:BX43,"<>0",avg-values)÷1000

tomorrow the range will extend to BY43

so every day I have to edit the formula to extend the range, is there any way I can get the formula to automatically extend the range to the end of the row?

iPad Pro, iPadOS 17

Posted on Nov 7, 2024 3:14 AM

Reply
Question marked as Top-ranking reply

Posted on Nov 7, 2024 2:58 PM

Hi Snout,


You can reference a whole row like this:

Formula is in a Header Column.


Formula in B2 is AVERAGEIF(2:2,">0")


To get the 2:2, click on the column number (2).

As you add new columns, the formula will automatically expand.


Regards,

Ian.

13 replies

Nov 7, 2024 8:10 PM in response to Snout71

That's sounds like an "Excelsy" format. Is there a reason you need such a wide table? (Financial reports, perhaps, where the convention is to have years or quarters across the top?)


If you're going to be adding new data it often works better to set things up so you enter it in new rows rather than new columns.


You could designate the first five rows as header rows (equivalent to your columns A through E) with the rest body rows (your F through BX and expanding).


Then add a Footer Row and put your formula in it. If your data is in, say, column B, then you formula is simply

=AVERAGEIF(B,"<>0")/1000.


Advantages:

  • The formula is dead simple.
  • New data is automatically included as you add it.
  • "Tall" tables are easier to work with than "wide" tables, which can get unwieldy as you add lots of columns.


Bonus:If you happen to have formulas in some of the other columns then Numbers automatically copies these down into new rows when you add one by selecting the last row and hitting <return>.


If you want to experiment with this type of approach then you can make a copy of your table (click the concentric rings to its upper left and option-drag onto the canvas). Then click somewhere in the copy and choose Table > Transpose Rows and Columns from the menu.


SG







Nov 7, 2024 11:33 AM in response to Snout71

There are a couple of ways of approaching this, depending on your appetite for creativity, as well as the specifics of your table. :)


Assuming the data fills your table, you can use the COLUMNS() function to find the number of columns in the table. This will increase each time you add a new column.

Note: this technique may fail if your table exceeds the number of columns, so try it and if we need to rework it we will... I always prefer the simple options first :)


So COLUMNS(Table 1::43) will return the number of columns in that row.


You can pass this number into INDIRECT() to calculate a reference. For example:


=INDIRECT("Table 1::R43C"&COLUMNS(Table 1::43), FALSE)


will return a reference to the last cell in row 43 (the FALSE at the end tells Numbers you're using R1C1 format rather than than the more common A1-style, and this saves us from having to convert the column number to an index (e.g. 'BX')


INDIRECT() works by taking a textual description of a cell (or range) and converting it into references that other functions can work with.


You can extend the INDIRECT() function to return a range instead of a single cell, like:


INDIRECT("table 1::R43C6:R43C"&COLUMNS(Table 1::43:43),FALSE)


So now we have a reference that points to Row 43, Column 6 (or F) through the last column in row 43


We can pass this into your existing AVERAGEIF() function, thus:


=AVERAGEIF(INDIRECT("table 1::R43C6:R43C"&COLUMNS(Table 1::43:43),FALSE),"<>0")


which looks like this:



Now you'll get an average of all the non-zero cells in row 43, from column F to the end of the table.

Nov 8, 2024 3:31 AM in response to Snout71

Hi Snout,


Is there a real need to have Columns A, B, C, D and E attached to the left of your data table? What do those columns contain? What is there purpose?


More information on your overall aim may get our creative juices flowing. A screen shot of a few columns of your data table will help us visualise the layout of your document.


Perhaps this will kick off some discussion. An idea using the Numbers approach of separate tables, each with a purpose:



No formulas in the Data table.

Summary table allows for several statistics. Also, the summary table can be moved to another Sheet as a Presentation.


Happy Numbering!

Ian.

Nov 8, 2024 2:19 PM in response to Snout71

Hi Snout,


Thanks for the screen shot. That brought on an "Aha" moment. Columns A to E are Header Columns (the clue is that they are frozen and other Columns (up to BM) have been scrolled "behind" them. Good. (BTW, did you hide Column A?) Numbers allows up to 5 Header Columns, so you are up to the max.



One complication that I see is the merged cells (e.g. 4, 5, 6, 7). I don't know how that will affect formulas for Avg Tourn and Avg event.


But we are progressing!


Regards,

Ian.



Nov 9, 2024 2:29 AM in response to Yellowbox

Hi Snout,


Will this work for you?

From your screen shot, there are up to four scores for each player on each date.

I saw the need to identify the four "Rounds" then calculate Avg Tourn and Avg Event for each "Round", then sum them in a Summary table. Does that make sense?


In the Data table I took out the merged cells (they could cause glitches). I made each row a unique record (Player name in every row). That makes it easier to SUMIF over each Player and Round. Five Header Rows - as five is the max that Numbers allows per table, that's another reason for the Summary table.


What is in your hidden Column A?

What is the purpose of the numbers in my Column A? I had to use your Column A.


If you think that this layout will work for you, let me know and I will insert the "whole row" formulas for Avg Tourn and Avg Event.


Regards,

Ian.

Nov 9, 2024 3:26 AM in response to Yellowbox

Hidden in column A is a ROW formula that allows column B to remain in numerical order, the reason is that I move players up and down the order depending on how they are performing (the top player is at the top) but before when I moved the order the numbers didn’t change, now they do.

luckily for me the formulas are not affected by the merged cells

Nov 9, 2024 3:41 AM in response to Yellowbox

Ok, so

row 4 is only filled at the end of each tournament (2/3/4 weeks long) if “End” is located in row 2 the end figure in row 5 is multiplied by the multiplier I will enter in row 3

this is because I want each number at the end of tournaments to be 4 weeks, which is the norm, but sometimes they’ll do a short tournament of 3 weeks so I multiply by 1.333 to make it 4 weeks, if it’s 2 weeks I’ll double. Row 4 is used for the formula in column D.

row 5 is the daily figure I’ll grab from the game which is currently the only manual thing I have to do

row 6 is the daily score they managed (formula of that days score minus the previous days score)

row 7 is filled if “event” is located in row 2 and is a copy of row 6 but which is used for the formula in column E

Nov 7, 2024 4:25 PM in response to Yellowbox

> You can reference a whole row like this:


Except that does not solve the OP's problem.


Yes, you can reference an entire row (or column) in this way, but the OP wants a subset of the cells in that row.


>AVERAGEIF(F43:BX43,"<>0",avg-values)÷1000


There is no way to reference the entire row MINUS the first 5 columns (A-E) using this method. You have to build a reference to the cells you DO want. My INDIRECT() approach is one way of doing that.

Nov 8, 2024 8:52 AM in response to Yellowbox

To be honest it’s nothing as important as a financial spreadsheet or anything but rather my managing a team for a game. I keep track of everybody’s activity on a daily basis (sometimes every other day), that’s 50 players in each team, two teams

The average function keeps tracks of players average performance in weekend events as well as monthly tournaments, the totals of which are kept in left hand column next to player names but divided by 1,000 to be easier on the eye. I keep adding things to the chart to make it a little more automated

Average of cells to end cell of row which is always growing

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.