> For the complete documentation index, see [llms.txt](https://help.pickzen.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.pickzen.com/guides/nocode/functions/prescribe.md).

# PRESCRIBE

### Syntax

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

| Argument name                                       | Description                                                                                                                                                                                       |
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><strong>table</strong></p><p>Required</p>        | Table to evaluate containing the prescription rules. See below.                                                                                                                                   |
| <p><strong>rowsSelector</strong></p><p>Optional</p> | Selector of rows. All rows by default.                                                                                                                                                            |
| <p><strong>colsSelector</strong></p><p>Optional</p> | Selector of columns. All columns by default.                                                                                                                                                      |
| <p><strong>condition</strong></p><p>Optional</p>    | <p><strong>matchall</strong> Only adds an item if it is contained in all matching rows.</p><p><strong>matchany</strong> (default) Adds an item if it is contained at least in a matching row.</p> |
| <p><strong>out</strong><br>Optional</p>             | Also includes the results in a list.                                                                                                                                                              |

**Table syntax:**

| Column name                                             | Description                                                                                                                        |
| ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| <p><strong>answer</strong></p><p>Required, Multiple</p> | Answer rules to evaluate.                                                                                                          |
| <p><strong>mode</strong></p><p>Optional</p>             | <p><strong>include</strong> (default) Includes the items (if not excluded).</p><p><strong>exclude</strong> Excludes the items.</p> |
| <p><strong>weight</strong></p><p>Optional</p>           | Assigns points to items that will be used to order them.                                                                           |
| <p><strong>rule</strong></p><p>Optional</p>             | Selects items based on attribute rules.                                                                                            |
| <p><strong>\<other columns></strong></p><p>Required</p> | Any other column is treated as items holder.                                                                                       |

### Examples

#### Example 1

![mytable](/files/-MA5ls7s4O9diFnPiD9U)

**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

![mytable](/files/-MA5mKz4dtyIvCTaUcsn)

\
**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

![mytable](/files/-MA5n2eEzSFzpUMVdOiw)

We can also use formulas that will be evaluated.

#### Example 4

![mytable](/files/-MA5nNWJlnrRT_ElniCb)

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

![mytable](/files/-MA5pGzwdc0kUBS-rgyg)

**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

![mytable](/files/-MA5qzCkyEb-aTBe3vLc)

**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

![](/files/-MLmitzhQOa9DInfLHTg)

**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.
