Forgive me if I'm asking an old question. I've done a bit of searching for an answer.
Imagine a sheet in which cell Y contains a formula including a reference to cell X, and cell Z contains a formula which references both cell X and cell Y.
My question is this: when the formula in cell Z accesses the value of cell Y, does it get the value before or after it is modified by the formula in cell Y?
In my imagination I have a model in which cells are calculated in a top to bottom and left to right sort of sequence. Is this correct? Or would a situation like this be resolved by forcing recalculation of Y as part of the calculation of Z?
In case that was too abstract, imaging a sheet with a row for Nett pay (calculated as gross pay - tax), then a row for gross pay, then a row with a formula to calculate tax. Would Nett pay be calculated before the tax calculation because it was positioned higher up on the spreadsheet?
[Solved] What order are cells with formulas calculated?
[Solved] What order are cells with formulas calculated?
Last edited by MrProgrammer on Mon Jan 04, 2021 4:55 am, edited 1 time in total.
Reason: Tagged ✓ [Solved]
Reason: Tagged ✓ [Solved]
Re: What order are cells with formulas calculated?
I've tried a very simple version of this as shown below, and it seems to update the calls intelligently rather than in a top to bottom, left to right fashion. I.e. if I put a different value in Gross pay then Nett pay is updated suitably. But I'm unclear where this is documented and whether it always works, and if so, how. Does it somehow follow references and also evaluate the referenced cells before any cells which refer to them?
A B C
1 nett pay C2-C3 £1,760
2 gross pay 2200 £2,200
3 Tax (C2-1000)*0.2 £440
A B C
1 nett pay C2-C3 £1,760
2 gross pay 2200 £2,200
3 Tax (C2-1000)*0.2 £440
Last edited by RobEW on Thu Jan 03, 2019 6:10 pm, edited 1 time in total.
LibreOffice 5.4.1.2
Windows 7
Windows 7
- MrProgrammer
- Moderator
- Posts: 5479
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: What order are cells with formulas calculated?
Hi, and welcome to the forum.
Formulas which depend on only static data values are evaluated first. Formulas which depend on those first formula calculations are calculated evaluated second. Formulas which depend on the second calculations are evaluated third. Eventually all the formulas are evaluated because mutually-dependent formulas are not allowed in spreadsheets.
If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
[Tutorial] Ten concepts that every Calc user should know
After.RobEW wrote:When the formula in cell Z accesses the value of cell Y, does it get the value before or after it is modified by the formula in cell Y?
No.RobEW wrote:In my imagination I have a model in which cells are calculated in a top to bottom and left to right sort of sequence. Is this correct?
Yes.RobEW wrote:Or would a situation like this be resolved by forcing recalculation of Y as part of the calculation of Z?
Yes, always. That's the key.RobEW wrote:Does it somehow follow references and also evaluate the referenced cells before any cells which refer to them?
Formulas which depend on only static data values are evaluated first. Formulas which depend on those first formula calculations are calculated evaluated second. Formulas which depend on the second calculations are evaluated third. Eventually all the formulas are evaluated because mutually-dependent formulas are not allowed in spreadsheets.
If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
[Tutorial] Ten concepts that every Calc user should know
Last edited by MrProgrammer on Fri Jan 04, 2019 12:02 am, edited 2 times in total.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
Re: What order are cells with formulas calculated?
Thanks - very enlightening (and reassuring). Is this documented anywhere? I tried looking in the help and these forums and using Google ...
LibreOffice 5.4.1.2
Windows 7
Windows 7