How to create a variable with a calculation?

How to create a variable in ESP Home with a calculation?
This calculation should run only 1x at the beginning and should be accessible for other calculations.

Variable = 3.1415 * x*x*y

These variable is only for calculation in the ESPHome configuration - not for using in home assistant.

Thanks for your help

Use the on_boot event to update a template sensor.