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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.pickzen.com/guides/nocode/functions/prescribe.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
