## EZ Exporter Calculated Fields - Conditional Expressions

Conditional expressions allow you to include logic when generating your report.

AVAILABLE OPERATORS

• if ("this value" if "condition" else "", must be used with "else")
• else ("this value" if "condition" else "this other value", must be used with "if")
• not (if not "condition")
• and (both conditions must be True, if "condition1" and "condition2", if 1 == 1 and 1==2 -> False)
• or (either condition can be True, if "condition1" or "condition2", if 1 == 1 or 1 == 2 -> True)
• > (greater than, if 3 > 1 -> True)
• < (less than, if 1 < 3 -> True)
• >= (greater than or equal to, if 3 >=3 -> True)
• <= (less than or equal to, if 3 <= 3 -> True)
• == (equals, if 5 == 5 -> True)
• in (contains, if "shop" in "shopify" -> True)
• {{ text_field }}.startswith() (text starts with characters, "hello".startswith("he") -> True)
• {{ text_field }}.endswith() (text ends with characters, "hello".endswith("h") -> False)
• {{ text_field }}.isdigit() (text only contains numbers, "090210".isdigit() -> True, "R2D2-V3".isdigit() -> False)

Note: Conditional expressions should always have a final "else" statement.

EXAMPLES

I want to categorize my orders based on total_price.

```"High" if {{ total_price }} >= 1000 else "Medium" if {{ total_price }} >= 100 else "Low"
```

This will assign the value "High" if the order's total_price is greater than or equal to 1000, "Medium" between 100-1000, and "Low" if below 100.

I want an additional field for the destination's region.

```"North America" if {{ shipping_address.country_code }} in "US, CA, MX" else "Other"
```

If the shipping address' country code is US, CA, or MX, assign the value "North America", otherwise, use "Other".

I want an additional field to set an order's priority based on price or weight.

```"High" if {{ total_price }} > 500 or {{ total_weight }} > 1000 else "Normal"
```

If the order's total price is above 500 or if the total weight is over 1000, mark this order as high priority.

I wan a column indicating the order is a high priority depending on the shipping address state/province.

`"High Priority" if ({{ shipping_address.province_code }} == "NY" or {{ shipping_address.province_code }} == "NJ") else ""`

Display "High Priority" if the shipping address state/province code is either NY or NJ.  Otherwise, just leave it blank.

Related Articles:

App: EZ Exporter