You can follow different ways to achieve this
1. From the load script you can create the KPI and use that field to display the KPI in the dashboard.
Sum(Sales) as Sales
2. In the expression level like with SET expression or any other expression.
This are very basic example you can follow different formula also for this depends on your KPI.