# Value steps

> Value steps calculate things in a workflow, from fixed values and comparisons to math, text, dates, lists, conversions, and locations.

Value steps calculate something: a sum, a formatted date, a subject line, a yes-or-no answer. They don't have a place in the run order. Each is worked out the moment a later step needs its result. Connect their outputs to the inputs of other steps.

## Fixed values

**String**, **Number**, **Boolean**, **Date Literal**, **Object**, and **Array** hold a value you type in. Use them for constants, such as a fixed email address or a threshold amount.

## Structured values

| Step | What it does |
| --- | --- |
| **Make Struct** | Builds a structured value from named fields that you define. |
| **Break Struct** | Splits a structured value back into its fields. |
| **Make Enum** | Picks one label from a fixed set you define, such as low, medium, or high. Use it with **Switch Enum**. |
| **Make Array** | Builds a list from separate inputs. |

## Comparisons and logic

- Compare two values with **Equal**, **Not Equal**, **Greater Than**, **Less Than**, **Greater or Equal**, and **Less or Equal**.
- Combine yes-or-no values with **And**, **Or**, and **Not**.

Connect the result to a **Branch** step to choose a path.

## Math

**Add**, **Subtract**, **Multiply**, **Divide**, **Modulo**, **Power**, **Min**, **Max**, **Clamp**, **Abs**, **Floor**, **Ceil**, and **Round**.

Dividing by zero gives an empty result rather than an error, so check for it if it can happen.

## Text

| Group | Steps |
| --- | --- |
| Join and measure | **Concat**, **Length**, **Template** |
| Case and spacing | **Upper Case**, **Lower Case**, **Trim**, **Remove Whitespace**, **Pad Start**, **Pad End** |
| Search | **Contains**, **Starts With**, **Ends With**, **Index Of** |
| Cut and replace | **Slice**, **Split**, **Replace**, **Replace All** |
| Patterns | **Regex Test**, **Regex Match**, **Regex Replace** |
| Encoding | **Base64 Encode**, **Base64 Decode**, **URL Encode**, **URL Decode**, **Hash** |
| Generate | **Random String** |

**Template** fills placeholders in a piece of text with values, which is the easiest way to build an email subject or a reference code. Use the pattern steps when the format really is a pattern, such as a customer-specific code. To check a whole input against a known shape, **Validate Schema** is usually simpler.

## Conversion

| Step | What it does |
| --- | --- |
| **To String** | Turns any value into text. |
| **To Number** | Turns text into a number. Gives an empty result if it can't. |
| **To Boolean** | Turns a value into yes or no. Empty text, zero, and empty values become no. |
| **JSON Parse** | Reads JSON text into a value, such as the body of an HTTP response. |
| **JSON Stringify** | Turns a value into JSON text. |

## Dates and times

| Group | Steps |
| --- | --- |
| Create | **Now**, **Date Literal**, **Parse Date**, **Date From Parts**, **From Unix**, **From Unix (ms)** |
| Format | **Format Date**, **To Unix**, **To Unix (ms)**, **To Timezone** |
| Parts | **Year**, **Month**, **Day**, **Day of Week**, **Hour**, **Minute**, **Second** |
| Calculate | **Add**, **Subtract**, **Diff**, **Start Of**, **End Of** |
| Compare | **Before**, **After**, **Equal** |

For example, use **Add** with 30 days for a due date, **Start Of** with "day" for midnight, and **Diff** to count the days between two dates. **Format Date** uses a pattern such as `%d.%m.%Y` and can convert to a time zone first, such as Europe/Berlin.

## Lists

| Group | Steps |
| --- | --- |
| Read | **Get Element**, **Array Length**, **Array Includes**, **Array Find**, **Array Find Index** |
| Change | **Array Push**, **Array Pop**, **Array Reverse**, **Array Slice**, **Array Concat**, **Array Sort**, **Array Distinct** |
| Totals | **Array Sum**, **Array Average**, **Array Min**, **Array Max** |
| Reshape | **Array Map**, **Array Filter**, **Array Group By** |

**Array Map** picks one field from every item, such as all customer IDs. **Array Group By** groups items by a field, such as invoices by customer. **Get Element** with -1 returns the last item.

## Locations

These work with the same points as a [Location column](/docs/columns/geo-point).

| Group | Steps |
| --- | --- |
| Create and read | **Make Geo Point**, **Break Geo Point**, **Geo Point From String**, **Geo Point To String**, **Format Geo Point** |
| Measure | **Distance**, **Bearing**, **Destination**, **Midpoint** |
| Check | **Within Radius**, **In Bounds** |
| Many points | **Centroid**, **Bounds**, **Nearest**, **Sort By Distance** |

For example, use **Nearest** to find the closest depot to a customer, or **Within Radius** to check whether an address is inside your service area. To turn a street address into a point, use **Geocode Address**, described in [Other systems](/docs/workflows/nodes/other-systems).

## Keep it simple

You rarely need to plan every calculation step. Describe the result, such as "the subject is the order number and customer name", and build it with the steps above. Spell out a calculation only when it's a business rule in its own right, such as how a discount is worked out.

  - [Workflow steps](/docs/workflows/nodes): How steps and values work together.
  - [Flow steps](/docs/workflows/nodes/flow): Branches that use comparisons.

---

Source: https://community.sapugo.app/docs/workflows/nodes/values
