> 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

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

### 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](https://1947171238-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LrTaL6FQB3RzlkCwQfN%2F-MA5hGe8A5qsQMFVB-iB%2F-MA5ls7s4O9diFnPiD9U%2Fimage.png?alt=media\&token=8ffe5cb4-c510-456e-8088-caf4d3fc947b)

**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](https://1947171238-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LrTaL6FQB3RzlkCwQfN%2F-MA5hGe8A5qsQMFVB-iB%2F-MA5mKz4dtyIvCTaUcsn%2Fimage.png?alt=media\&token=f804d5b5-5588-4739-bd01-b89b9e508c58)

\
**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](https://1947171238-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LrTaL6FQB3RzlkCwQfN%2F-MA5hGe8A5qsQMFVB-iB%2F-MA5n2eEzSFzpUMVdOiw%2Fimage.png?alt=media\&token=0aa40436-a880-466d-aa6c-9462558a2677)

We can also use formulas that will be evaluated.

#### Example 4

![mytable](https://1947171238-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LrTaL6FQB3RzlkCwQfN%2F-MA5hGe8A5qsQMFVB-iB%2F-MA5nNWJlnrRT_ElniCb%2Fimage.png?alt=media\&token=0329d6f9-d39b-473e-b05f-fccbf1d54a32)

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](https://1947171238-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LrTaL6FQB3RzlkCwQfN%2F-MA5hGe8A5qsQMFVB-iB%2F-MA5pGzwdc0kUBS-rgyg%2Fimage.png?alt=media\&token=83ecfbd2-3a96-4465-9f58-84ceedc3e526)

**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](https://1947171238-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LrTaL6FQB3RzlkCwQfN%2F-MA5hGe8A5qsQMFVB-iB%2F-MA5qzCkyEb-aTBe3vLc%2Fimage.png?alt=media\&token=f45c9995-ad72-4baf-b895-5c7345a6eff9)

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

![](https://1947171238-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LrTaL6FQB3RzlkCwQfN%2F-MLmiUo8ZyoQNEVt_A3l%2F-MLmitzhQOa9DInfLHTg%2Fimage.png?alt=media\&token=ba9afba3-9d66-4565-9679-106b922c6396)

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