PRESCRIBE

The PRESCRIBE function evaluates answer rules and returns items based on these rules.

Syntax

PRESCRIBE(table, [rowsSelector, colsSelector, condition, out])

Table syntax:

Examples

Example 1

PRESCRIBE(mytable) If a1 is true, returns sku1 If a2 is true, returns sku2 and sku3 If a1 is true and a2 is true, returns sku1, sku2, sku3

Example 2

PRESCRIBE(mytable) If a1 is true and a2 is true, returns sku3, sku1, sku2. Note sku3 is returned in the first place because it has more weight as it appears in two matching rules.

Example 3

We can also use formulas that will be evaluated.

Example 4

We can use multiple answer columns. In this case, answer columns in each row have to be evaluated as true for the rule to be met.

PRESCRIBE(mytable) If a1 is true and a2 is true, returns sku2 If a1 is true and a3 is true, returns sku1

Example 5

PRESCRIBE(mytable) If health_bones is true and heath_sleep is true, returns sku2 and sku1. Note sku2 has more priority because of its assigned weight. If health_bones, heath_sleep, and allergy_fish are true, returns only sku2 because sku1 will be excluded according to rule 3.

Example 6

PRESCRIBE(mytable, ':', ':', 'matchall') If a1, a2, and a3 are true, it returns sku2 because it is the unique item that appears in all matching rules according to the matchall condition. If a1, and a4 are true, it returns nothing because there are no items that appear in all matching rules.

Example 7

PRESCRIBE(mytable, ':', ':', 'matchall') If a1 and a3 are true, it returns those products with tag cleanser that have size greater than 10. If a2 and a3 are true, it returns those products with tag serum or essential oil, that have size greater than 10.

Last updated