--- alias: tutorials-weigh-and-dispense-calculate-quantities tags: - "11.3" description: "Understand how the system calculates the quantities to weigh and their tolerances for the Relative and Absolute formula types, and how a Rule can calculate them automatically" --- # Calculate the Quantities to Weigh In this scenario, you will learn how to: - Calculate the quantity to weigh and the tolerance limits of each ingredient for the Relative and Absolute formula types. - Understand how the system calculates the minimum tolerance. - Calculate the quantities automatically with a **Rule**. !!! info For more information, see: - [[tutorials-howto-createbomforweighanddispense]] - [[tutorials-howto-settargetquantityformaterial]] - [[user-guide-manage-bomitems]] ## How the System Calculates the Quantities The system calculates the quantity of each ingredient against the **Target Material Quantity** of the target **Material**. The calculation depends on the formula type of the **BOM**. The following examples use a target quantity of 25 Kg. ### Relative Formula Type In a Relative **BOM**, the quantities are percentages and the tolerances are percentages of the calculated quantity. The system calculates the following values for each item: ```text Required Quantity = Target Quantity × Quantity / Sum of the Quantities Lower Limit = Required Quantity × (1 - Lower Tolerance / 100) Upper Limit = Required Quantity × (1 + Upper Tolerance / 100) ``` The following table shows the calculation for `BOM W&D Compound B`. The sum of the quantities is 100. | Product | Quantity (%) | Lower Tolerance (%) | Upper Tolerance (%) | Required Quantity (Kg) | Lower Limit (Kg) | Upper Limit (Kg) | | --- | --- | --- | --- | --- | --- | --- | | `Powdered chemical Blue` | 20 | 0.1 | 0.01 | 5.0000 | 4.9950 | 5.0005 | | `Phthalates` | 80 | 2 | 1 | 20.0000 | 19.6000 | 20.2000 | Table: Quantities to weigh for a Relative BOM !!! info The sum of the quantities of a Relative BOM must be between 99 and 101. When the sum is not 100, the system adjusts the quantities, so that the required quantities add up to the target quantity. ### Absolute Formula Type In an Absolute **BOM**, the quantities and the tolerances use absolute values. The sum of the quantities can be any value, so the system scales the quantities and the tolerances to the target quantity with the following factor: ```text Factor = Target Quantity / Sum of the Quantities Required Quantity = Quantity × Factor Lower Limit = Required Quantity - Lower Tolerance × Factor Upper Limit = Required Quantity + Upper Tolerance × Factor ``` The following table shows the calculation for `BOM W&D Compound G`. The sum of the quantities is 55 Kg, so the factor is 25 / 55. | Product | Quantity (Kg) | Lower Tolerance (Kg) | Upper Tolerance (Kg) | Required Quantity (Kg) | Lower Limit (Kg) | Upper Limit (Kg) | | --- | --- | --- | --- | --- | --- | --- | | `Powdered chemical Green` | 5 | 0.1 | 0.05 | 2.2727 | 2.2273 | 2.2955 | | `Phthalates` | 30 | 2 | 1.5 | 13.6364 | 12.7273 | 14.3182 | | `Secret Chemical Recipe` | 20 | 0.1 | 0.05 | 9.0909 | 9.0455 | 9.1136 | Table: Quantities to weigh for an Absolute BOM The required quantities add up to the target quantity of 25 Kg. The tables round the values to four decimals. The Weigh and Dispense page can show a different number of decimals, according to the precision of the selected scale. ### Add Notes to Support the Operator In both formula types, you can add a **Note** to each **BOM** item with instructions for the operator. The system shows the note on the **Weigh & Dispense** page when the operator selects the ingredient. ## How the System Calculates the Minimum Tolerance The system calculates the minimum tolerance of an ingredient. The calculation takes into account the Measurement Capabilities of the selected **Instruments** and the selected **BOM** items. The calculation has the following steps: 1. Calculate the Minimum Tolerance as the smaller of the distances between the Required Quantity and the Lower Limit, and between the Required Quantity and the Upper Limit. If the Required Quantity equals one of the limits, the Minimum Tolerance is the distance to the other limit. 2. Divide the Minimum Tolerance by the value of the `PrecisionQuantum` configuration entry. The result is the Adjusted Minimum Tolerance. 3. If you do not set the precision test, calculate the Adjusted Minimum Tolerance with the following formula, where the Accuracy Quantum is the value of the `AccuracyQuantum` configuration entry: ```text Adjusted Minimum Tolerance = Minimum Tolerance / (Target Quantity × Accuracy Quantum) ``` !!! info The `PrecisionQuantum` and `AccuracyQuantum` entries are under `/Cmf/System/Configuration/WeighAndDispense/`. For more information, see [[tutorials-weigh-and-dispense-prerequisites]]. ## Calculate the Quantities Automatically with a Rule A **BOM** item can use a **Rule** and its DEE Action to calculate the Lower Tolerance, the Required Quantity, and the Upper Tolerance. 1. Create a **Rule** that returns the Lower Tolerance, the Required Quantity, and the Upper Tolerance in the units that the **BOM** defines. For more information, see [[user-guide-rule-page]]. 2. In the **BOM Items** of the **BOM**, select the **Rule** in the **Quantity Calculation Rule** column of the item. 3. Optionally, add a **Note** to the item with instructions for the operator. When the operator begins weighing an ingredient with a **Rule**, the system calls the **Rule** and behaves as follows: - If the **Rule** returns an error, the system shows the error to the operator and the operation cannot begin. - If the **Rule** succeeds, the system updates the Lower Tolerance, the Required Quantity, and the Upper Tolerance on the page, and the operator can proceed. A visual notation next to the ingredient indicates that the quantities come from a **Rule**. ![Ingredients list with a function icon next to the ingredient that uses a Quantity Calculation Rule.](images/quantity_calculation_rule.png) ## Expected Result You know the quantity and the tolerance limits that the system expects for each ingredient. The next scenarios use these values. ## Next Scenario Continue with [[tutorials-weigh-and-dispense-single-step]].