Confused On Circular Reference

valleyHemenway

New Member
Joined
Nov 17, 2022
Messages
11
Office Version
  1. 365
Platform
  1. MacOS
Hello,
My goal is to write a formula I can use in a table that creates an "ID" number sequence down the table. I skip some rows depending on values in other columns. So the first row will always have ID 1 and then it might be a few rows before I would expect ID 2 to show up and then eventually 3 and so on.

I do not want to use any specific references (A3). I have what seems to to be a workable formula, but it also acts like there is a circular reference. I have to click into any cell and press ENTER or press F9 before the values change to what they are supposed to be. There is no circular reference error in Excel, and I don't see how my formula creates one. I am stumped.

Does anyone know if I am actually creating a circular reference? Can anyone come up with a different way of creating my "auto-numbering" feature?

Thanks so much!

test.xlsx
CDEFG
3
4Column1Column2Column3
510
6 A
7 B
8 C
910
10 A
11 B
1210
13 A
1410
1510
1610
17 A
18 B
1910
2010
21 A
2210
23 A
24 B
25
Sheet1
Cell Formulas
RangeFormula
D5:D24D5=IF(ISTEXT([@Column2]), "", MAX(INDIRECT(ADDRESS(ROW(Table1[#Headers]),COLUMN([Column1])) & ":" & ADDRESS(ROW()-1,COLUMN([Column1]))))+1)
 
Just tried closing and reopening it and it is working fine. If you want to put your workbook on a shared server eg drop box, google drive etc I am happy to take a look.
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
I have a large spreadsheet this is happening on.
I am still not having any issues with your original formula in terms of it refreshing the values.
Do you actually have the issue with the test file you sent me ?
It might be something to do with the size of your actual spreadsheet ?

Also the file you sent me was an XLSX, is your original file an XLSM or XLSB. If that is the case are there any event macros in the sheet or on opening the Workbook.

also you can try disabling any Add-Ins you have installed and active, to see if that makes a difference.
I will tackle the Offset question separately.
 
Upvote 0
The original file and the test file are both XLSX files. No macros in them. The file is only 268K so not large. I have tried the original spreadsheet on more than one system and was having the issue. However, I am about to clean install the latest OS on my computer, so once I do that I will try the test spreadsheet again and see if I get the same results. Just for the heck of it though, I uploaded the test file to my OneDrive and it didn't have the issue I am having locally. I am wondering if it is a Mac Excel issue.
 
Upvote 0
An alternative,
Excel Formula:
=LET(ab,BYROW([Column2],LAMBDA(x,IFNA(ROW(XLOOKUP(0,x,x,,,-1)),""))), IF([@Column2]=0,COUNT(FILTER(ab,ab<=ROW())),""))
 
Upvote 0
Also, why do you avoid OFFSET, have you seen issues with compatibility or something else?
Indirect and Offset are 2 of 10 or so functions that are Volatile. In layman's terms what that means is that whereas other functions only recalculate when any of the cells that feed into it change, "volatile formulas get automatically recalculated any time you enter data anywhere in any open workbook" (per Chandoo - Link below)
Handle Volatile Functions like they are dynamite » Chandoo.org - Learn Excel, Power BI & Charting Online

Indirect is probably top of the list in terms of formulas to avoid, see Charles Williams link below and who is probably the most quoted source when it comes to Excel performance.
INDIRECT – Excel’s Most Evil Function

@jaeiow has given you another option which avoids both and here is yet another one:
Excel Formula:
=IF(ISTEXT([@Column2]), "",
         MAX(Table1[[#Headers],[Column1]]:
                   INDEX(Table1[[#All],[Column1]],ROW([@Column1])-ROW(Table1[[#Headers],[Column1]]),0)
                  ) + 1
      )

Note: Also per Charles Williams, Conditional formatting also behaves in a manner similar to Volatile Functions, and if you have a lot of them in your spreadsheet that may also account for the "Indirect" refresh issue you are experiencing.
 
Last edited:
Upvote 0
My formula is not reliable. I'm not sure how to write a lambda-type of function in a table without scanning the whole column, making it inefficient.
 
Upvote 0
This was my original intention with the Xlookup (last to first). Omits the byrow, which was adding no value. Doesn't/can't use solely structured reference, which is no good, but with a "speedy lookup" can calculate fairly quick.
Excel Formula:
=IF(ROW()=3,
        1,
LET(
  Cat, 0,
    IF([@Column2]=Cat,
          LET(
            ab,
                IFNA(XLOOKUP(Cat,
                E2:E$3,
                D2:D$3,,0,-1),""),
            ab + 1),
    ""))
 
Upvote 0
Indirect and Offset are 2 of 10 or so functions that are Volatile. In layman's terms what that means is that whereas other functions only recalculate when any of the cells that feed into it change, "volatile formulas get automatically recalculated any time you enter data anywhere in any open workbook" (per Chandoo - Link below)
Handle Volatile Functions like they are dynamite » Chandoo.org - Learn Excel, Power BI & Charting Online

Indirect is probably top of the list in terms of formulas to avoid, see Charles Williams link below and who is probably the most quoted source when it comes to Excel performance.
INDIRECT – Excel’s Most Evil Function

@jaeiow has given you another option which avoids both and here is yet another one:
Excel Formula:
=IF(ISTEXT([@Column2]), "",
         MAX(Table1[[#Headers],[Column1]]:
                   INDEX(Table1[[#All],[Column1]],ROW([@Column1])-ROW(Table1[[#Headers],[Column1]]),0)
                  ) + 1
      )

Note: Also per Charles Williams, Conditional formatting also behaves in a manner similar to Volatile Functions, and if you have a lot of them in your spreadsheet that may also account for the "Indirect" refresh issue you are experiencing.
Thanks for the wonderful explanation! I do have a couple conditional formatting rows setup in the main excel sheet, but since it is also happening on my test file which doesn't, I think it likely has something to do with either Excel for Mac or Excel for Mac on M1. Either way, while not super ideal, the OFFSET option is working and is not causing the issue I was seeing before. After I reload and test again, I will report back. I will also see if I can test it on a Windows computer with Excel and see how that performs.
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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