---
url: /set-instructions/link-to-another-workview-using-formula.md
description: >-
  Makes each row or column header in a Workview clickable, with the destination
  computed per element by a formula.
---

# Link To Another Workview Using Formula

**Workview-only.** Makes each element's row or column header clickable, navigating to a destination computed per element by a formula. The formula is evaluated for every element in the working list, so each header can point somewhere different based on its own context.

This is how a Workview becomes a navigation surface rather than a dead end - a summary by department where clicking a department opens the detail screen for that department.

| Argument | Type | Description |
| --- | --- | ------ |
| Formula | Formula | The formula to evaluate for each element in the working set. Returns the destination, or an empty string to leave that header unlinked. |

Returning an empty string is how you link some headers and not others - a consolidation header can be left inert while its children link through to detail.

## Passing the element as an argument

A destination is usually a screen route, and the useful part is passing *which* element was clicked. The formula builds that URL by concatenating string literals with values, using the `&` operator:

```
"department-detail?6ad83e6275498f152a2d74e1784c4c21=" & URLENCODE(ELEMENT("Department"))
```

[`ELEMENT`](/cube-functions/element) returns the element from the named dimension for the header being evaluated, so each row produces its own destination. Clicking the `Sales & Marketing` header navigates to `department-detail?6ad83e6275498f152a2d74e1784c4c21=Sales%20%26%20Marketing`.

::: tip The argument name is the dimension's ID
Scope the destination by a dimension by using that **dimension's ID** as the query string argument name, not a label of your own. The ID is in the address bar when the dimension is open in the [Dimension Editor](/technical/managing-dimension-manually) - open the dimension and read it from the URL.
:::

::: warning Always encode values you interpolate
Element names routinely contain spaces, ampersands and slashes, all of which break a URL if passed raw. Wrap any interpolated value in [`URLENCODE`](/cube-functions/urlencode) - `Sales & Marketing` becomes `Sales%20%26%20Marketing`, which survives the round trip intact.
:::

More than one dimension can be passed by joining the pairs with a literal `&` inside the string:

```
"variance-detail?6ad83e6275498f152a2d74e1784c4c21=" & URLENCODE(ELEMENT("Department")) & "&b91c40d7e5a2183f6cd9074be2115a83=" & URLENCODE(ELEMENT("Scenario"))
```

Note the two different uses of `&` here: the operator that joins the parts of the formula together, and the `&` *inside* a quoted string that separates one query string argument from the next.

## How the argument reaches the destination

Nothing on the destination screen has to read the URL. Passing the argument writes the value into the browser's **local storage**, against the dimension element or variable named by the ID. Any selectable bound to that same ID then populates itself from it.

That's why the argument name has to be the dimension's ID rather than a label of your own - the ID is the key the value is stored under, and the key a selectable looks up.

Because this works through local storage, which selectables respond depends on whether they persist:

| Selectable | Picks up a passed value |
| :--- | :--- |
| Workview title selectable | Always - these always persist, with no way to turn it off |
| [Card Selectable](/card-guides/selectable) | Only when its **Persist** property is set to `Yes` |
| Dashboard Selectable widget | Automatically when it updates dimension context, but **not** when configured to update a variable instead |

::: warning A passed value outlives the click
Because the value is written to local storage rather than just applied for the one page load, it persists on return visits until the user selects something else. It also takes precedence over [Set Default Using The Next Instruction](/set-instructions/set-default-using-the-next-instruction) on the underlying set - so a linked-to screen shows the passed element rather than the set's default.
:::

## Example

```
1. Element: All Departments
2. Expand
3. Remove Consolidations
4. Link To Another Workview Using Formula: "department-detail?6ad83e6275498f152a2d74e1784c4c21=" & URLENCODE(ELEMENT("Department"))
```

Lists every leaf department and makes each one a link into its own detail screen, with the consolidation rows removed so only the linkable rows remain.

## Related

* [URLENCODE](/cube-functions/urlencode) - encoding values safely into a URL
* [Screens](/technical/screens) - the pages these links navigate to
* [Menus](/technical/menus) - the other route between screens, for fixed application-wide navigation
* [Apply Style Using Formula](/set-instructions/apply-style-using-formula) - making linked headers visually distinct
