Monday, September 24, 2007

Circular Reference in Excel

Not many people might have seen this error message, but I used to see it quite often during the time I used to be a business analyst for financial software.

This comes when you do something like I did below:So basically, I had 1 in the first cell, the third was the sum of the two cells on the left and the fourth was the sum of the second and third.

or D3=1, E3=2, F3=D3+E3, G3=E3+F3

Finally, I made D3=G3/2. Hence making D3 dependent on itself and hence the circular reference. Now something like this is not very common in everyday mathematics. But if you are trying to model an algorithm, this is very much required. And this is what I was trying to do.

While this is a simple example and you can very easily just write it such that multiple iterations are performed by just dragging, financial calculations usually used to run into 20-30 columns. Think forex forwards and interest rate swaps. And when you model these calculations in software, you use a lot of loops, be it if else, while, etc etc.

Now the problem comes when you have to test these algorithms. It is not enough to test the final result, you have to test each step. Which means you need some s/w which lets you simulate the condition effortlessly and excel does that, now only if it supported loops (without getting your hands dirty by writing macros).

The solution is simple, if the user attempts to do circular referencing, detect it, and automatically move the next iteration below (or to the side, or another sheet), let him choose the number of iterations, and he's a happy man.

Incidentally, this problem and the solution got me into Aditi :)

5 comments:

Upma_Sharma said...

Try doing 850*77.1 and have a look at the result. It gives a result of 100,000 instead of the correct 65,535. Read about Excel 2007 Multiplication Bug at http://it.slashdot.org/article.pl?sid=07/09/24/2339203&from=rss.

Vinodh Nandakumar said...

wow... i can't believe my eyes..

Swati Rathi said...

Here MS explains how you can enable circular reference and set the number of iterations in Office 2007 http://office.microsoft.com/en-us/excel/HP100662431033.aspx
Nice!
But when I tried to use this help on an excel sheet- I didn't find the checkbox "Enable iterative calculation". May be the intention was there but they "re-prioritized" the features!
Do you see this option?

Arun said...

Swati- trust you to jump to life on anything that has the word excel in it. Have you downloaded the entire excel online help? :)

By the way, you need to go through the Big round Office button->Excel options. Voila, you have more features...Thats weird. I thought the ribbon allowed you to access all the features!

Kiran K. Karthikeyan said...

@swati

not able to find that help file, the link you sent is not working. though i won't be using it now, you would have got a big treat a few years ago because this caused me so much grief :)