# Dynamic Fields

### Intro to Dynamic Fields

A powerful feature that allows users to add custom fields (otherwise known as columns) to their order tables. These fields can be dynamically calculated based on user-defined formulas, providing real-time, tailored data insights. Whether you need simple value entries, complex mathematical operations, or conditional logic, Dynamic Fields offer flexibility and precision to enhance your planning and analysis.

### **Formula Format**

* **Plain Values**: Values without an `=` are stored as-is.
  * Example: `"value1"` is stored exactly as `"value1"`.
* **Calculated Values**: Values with an `=` are treated as formulas.
* **Special Characters:** If a field/column name has characters such as: `- + /` that might be interpreted as formula symbols, it's recommended to use backticks: `` ` `` to encapsulate column names. \
  For example: `` =item.`column-name-with-minus` ``

### **Cell References**

* **Format**: `item.field_name` or `row_id.field_name`
  * **item**: Refers to the current row.
  * **row\_id**: Combination of location and code (e.g., `BDGA_C0006`).
    * All spaces in row\_ids are replaced with: `_`
  * **Example**: `item.top_of_green` or `BDGA_C0006.top_of_green`

**Note**: Autocomplete helps reference values.

### **Mathematical Operations**

**Available Operations:** `*` , `+` , `-` , `/` , `^` (Exponent/Power)

### **Conditional Checks**

* **Syntax**: `IF(condition, result_if_true, result_if_false)`
  * Example: `=IF(item.on_hand_stock < 2, "Order", "OK")`
* **Operators**:
* &#x20;`=` (Equal)
* &#x20;`<>` (Not equal)
* &#x20;`>` (Greater than)
* `<` (Less than)
* `>=` (Greater than or equal)
* `<=` (Less than or equal)

### **Additional Sample Formulas**

* **Cell Reference**: `=BDGA_C0006.transit_stock`
* **Math Operation**: `=item.transit_stock + item.on_hand_stock * 5`
* **Aggregate**: `=SUM(item.transit_stock, item.on_hand_stock)`

**Supported Aggregates**: `AVG`, `COUNT`, `MAX`, `MIN`, `SUM`

### **Error Codes**

* **Division by Zero**: `#DIV/0!`
* **Invalid Reference**: `#REF!`
* **Invalid Column**: `#NAME?`
* **Invalid Formula**: `#VALUE!`<br>
