There are two ways to perform a calculation.
- By creating a calculated column for the library and use excel formulas
- Using SharePoint designer workflow.
This will help you to perform any calculations using workflow.

Select “Do calculation” from “Action”

you can perform basic mathematical operations like addition, multiplication, division, etc., and store into workflow variable.
Then the workflow variable can be updated into a library column