You can create a workflow by using SharePoint Designer workflow to calculate the value, and set the workflow automatically start only when an item is created.
You can set the actions like:
Set the Start Options like:
More information about how to create a workflow by using SharePoint Designer for your reference:
https://learn.microsoft.com/en-us/sharepoint/dev/general-development/creating-a-workflow-by-using-sharepoint-designer-and-the-sharepoint-wo