# Ds

The `ds` expression function is useful for when you want to use the value of a databox multiple times in one expression.

<table><thead><tr><th width="117" align="center">Function</th><th width="192" align="center">Sample Expression</th><th align="center">Databox Value</th><th align="center">Result</th><th>Comments</th></tr></thead><tbody><tr><td align="center"><code>ds</code></td><td align="center">Number*Number(ds)</td><td align="center">3</td><td align="center">9</td><td>‘ds’ represents the original DataBox Value. In this example 3x3 = 9</td></tr></tbody></table>

### Example 1

A simple example of this would be to use it to square a number, multiply it by itself.

<figure><img src="/files/ieGK97l922q0Ucg1VrJH" alt=""><figcaption></figcaption></figure>

The user enters a number which is written into the databox Examples.ds.

Examples.ds.Square value converts the value into a Number and then multiplies it by the original value Number(ds).

<figure><img src="/files/648vraW0J0DLgbEKaqHj" alt=""><figcaption></figcaption></figure>

**Number \* Number(ds)**

For example if you enter 9

Number(9) \* Number(9) = 81

The result is written into Script.Details and output to a message as shown below\...

<figure><img src="/files/XoKBbRO9Rf3PdtgejO1l" alt=""><figcaption></figcaption></figure>

### Example 2

A more complicated use would be to have an SQL query retrieve a value from a number of possible values from a database, then convert the retrieved value into something else.

This example uses a dynamic question to get a value from a database and write it to a databox, the expression in this databox then checks the value and outputs text to a message depending on the value. This has been used by a client to look up a numeric code from their Housing Database and convert this code into different phone numbers to call depending on the property location.

<figure><img src="/files/lBxiU1bGdRLmWbfx4hu1" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/v7vaTO09rlkWsyWF3cI4" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/idh2EWGkk41TP7wY5iDk" alt=""><figcaption></figcaption></figure>

So if the User selects RD then a value of 1 is returned and this is converted into "Diagnostics Scripts" FL returns 2 and converts into "Enquiry Scripts" ROL returns 3 and converts into "Repairs Online" EOL returns 4 and converts into "Enquiries Online" BEN returns 101 and converts into "Benefits" OC returns 102 and converts into "Office Care" Test returns 900 and converts into "Test Scripts"

The expression to do this is as follows:

<figure><img src="/files/GnpK1FiTXpksZidljhkY" alt=""><figcaption></figcaption></figure>

```
='1' Replace('True','Diagnostic Scripts') Replace('False', ds ='2' Replace('True','Enquiry Scripts') Replace('False', ds ='3' Replace('True','Repairs Online') Replace ('False', ds ='4' Replace('True','Enquiries Online') Replace ('False', ds = '101' Replace ('True','Benefits') Replace ('False', ds ='102' Replace ('True', 'Office Care') Replace ('False', ds = '900' Replace ('True', 'Test Scripts')))))))
```

This expression first looks to see if the value in the databox is '1', if it is then 'True' will be returned, in this case 'True' will be replaced with 'Diagnostics Scripts'. If it is not '1' it'll return a value of 'False',  in this case 'False' will then be replaced with the original value (ds) and the expression will check to see if that is '2', if so it'll return a value of 'True', the 'True will be replaced by 'Enquiry Scripts... and so on until either something has come up as 'True' or all the checks have resulted in 'False'. This is shown below\...

<figure><img src="/files/9xaAb64vMdi9iRQbZbRt" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/eilnquDnIkDF6yFEVIbd" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/5rVmEi9K71BDuelAKkk5" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/Zuaq7ei2jYynEVZ7g6eI" alt=""><figcaption></figcaption></figure>


---

# 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://docs.keyfax.biz/product-suite/admin/databox-expressions/additional-functions/ds.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.
