Skip to content
v3.3.0

Volatile functions

If you work with spreadsheet software regularly, then you’ve probably heard about Volatile Functions. They are distinctive because they affect the way the calculation engine works. Every cell dependent on a volatile function is recalculated upon every worksheet change triggered by the operations listed below (volatile actions).

HyperFormula uses a dependency tree to keep track of all related cells and ranges of cells. On top of that, it constructs a calculation chain which determines the order in which the recalculation process should be done.

Usually, only cells marked as “dirty” are calculated selectively. However, this is not the case when a volatile function exists somewhere within the workbook. Volatile functions are always treated as “dirty” and recalculated on most actions.

Depending on how many cells are dependent directly or indirectly on the volatile function, it may impact the engine’s performance. Use them with caution, especially in large workbooks.

Volatile functions are recalculated on every volatile action, regardless of the arguments passed in the function call. Functions that depend on the structure of the sheet act as if they were volatile but only on operations on the sheet structure, such as adding or removing rows or columns.

  • RAND
  • RANDBETWEEN
  • NOW
  • TODAY

Built-in functions that depend on the structure of the sheet:

Section titled “Built-in functions that depend on the structure of the sheet:”
  • COLUMN
  • ROW
  • COLUMNS
  • ROWS
  • FORMULATEXT

See the complete list of functions available.

These actions trigger the recalculation process of volatile functions:

DescriptionRelated method
Recalculate on demandrebuildAndRecalculate
Resume an automatic recalculation moderesumeEvaluation
Batch operationsbatch
Modify cell contentsetCellContents
Modify sheet contentsetSheetContent
Clear sheet contentclearSheet
Insert a rowaddRows
Remove a rowremoveRows
Insert a columnaddColumns
Remove a columnremoveColumns
Move a cellmoveCells
Move a rowmoveRows
Move a columnmoveColumns
Add a defined nameaddNamedExpression
Modify a defined namechangeNamedExpression
Remove a defined nameremoveNamedExpression
Add a sheetaddSheet
Remove a sheetremoveSheet
Rename a sheetrenameSheet
Undoundo
Redoredo
Cutcut
Pastepaste

The extensive use of volatile functions may cause a performance drop. To reduce the negative effect, you can try batching these operations.

There is a way to mark a custom function as volatile:

// this is an example of how the RAND function is implemented
// you can do the same with a custom function
'RAND': {
method: 'rand',
isVolatile: true,
},

You can find more information about creating custom functions in this section.