--- title: "Using Variables and Arguments" slug: "using-variables-and-arguments" updated: 2024-02-06T11:02:20Z published: 2024-02-06T11:02:20Z canonical: "kb.dataparc.com/using-variables-and-arguments" --- > ## Documentation Index > Fetch the complete documentation index at: https://kb.dataparc.com/llms.txt > Use this file to discover all available pages before exploring further. # Using Variables and Arguments **Purpose:** Learn to create a formula with a variable and multiple arguments. **Task:** Build a formula that calculates the cost per ton of a chemical addition to the process. Sample Formula = Flow of Chemical * Cost of chem / Production rate Use appropriate tags from your system or sample tags for the chemical flow and production rate. **Steps:** 1. Find tags for the chemical flow and production rate in Tag Browser and drag them onto a Trend. Note the units of each tag, as they are needed to do unit conversion in the calculation. ![](https://cdn.document360.io/59db2ca4-e512-446a-a143-a7c626447812/Images/Documentation/image023_020.jpg) 2. Right-click the Production Rate tag and choose **Script Editor**. ![](https://cdn.document360.io/59db2ca4-e512-446a-a143-a7c626447812/Images/Documentation/image025_016.jpg) 3. In the Script Editor, change the Script Type to **Formula**. ![](https://cdn.document360.io/59db2ca4-e512-446a-a143-a7c626447812/Images/Documentation/image027_018.jpg) 4. Name the formula by filling in the **Formula:** field with the formula name (no spaces or special characters). Change the Data Type to **Numeric**. ![](https://cdn.document360.io/59db2ca4-e512-446a-a143-a7c626447812/Images/Documentation/image029_014.jpg) 5. Click on the **Arguments** tab and create two arguments: > **ChemFlowTag** Type String > > **ChemCost** Type Double ![](https://cdn.document360.io/59db2ca4-e512-446a-a143-a7c626447812/Images/Documentation/image031_015.jpg) 1. Build the calculation in the formula area using Argument variables: Type: “OV = IV(ChemFlowtag) * ChemCost * 60 * 60 / IV” The logic is: Chemical in Liters/Second * Cost in $/Liter * 60 Second/Minute * 60 Minutes/ Hour which is all then divided by the production rate in Mt/Hr to get a final value of $/Mt. (If the units of the input tags are different from this example, make the necessary adjusments to the calculation logic). ![](https://cdn.document360.io/59db2ca4-e512-446a-a143-a7c626447812/Images/Documentation/image033_014.jpg) 2. Click the **Save Formula** button. 3. Drag the Chemical Flow tag from Tag Browser into the argument grid as the value of ChemFlowTag variable. ![](https://cdn.document360.io/59db2ca4-e512-446a-a143-a7c626447812/Images/Documentation/image035_015.jpg) 4. Type a number into the argument grid as the value of ChemCost variable. This will be used for calculating test results. ![](https://cdn.document360.io/59db2ca4-e512-446a-a143-a7c626447812/Images/Documentation/image037_011.jpg) 5. Click the **Run** button to see example results on the **Calc View** tab. ![](https://cdn.document360.io/59db2ca4-e512-446a-a143-a7c626447812/Images/Documentation/image039_003.png) 6. Add the calculated tag to the trend. Edit the tag name to manually change the value of the ChemCost variable. ![](https://cdn.document360.io/59db2ca4-e512-446a-a143-a7c626447812/Images/Documentation/image041_005.png)