Initializing help system before first use

# Using Dynamic Variables

Dynamic variables allow you to define calculations or operations once and reference them in multiple expressions.
This is implemented with the `<vdl-var>` element which defines a variable's name and its value. Once defined, the variable can be referenced throughout the rest of a View. Variable names should be unique and will be either globally-scoped or scenario-scoped, depending on where you define them.
Note: A `vdl-var` component will feature an orange border when placed on the artboard in View Designer. This designates that the item will not be visible in the view when it is published, although the value stored in the var can be displayed if it is attached to a `vdl-text` component.

## Globally scoped dynamic variables

The following view illustrates how to create and use globally-scoped variables.

View Designer
Code editor

    <vdl version="5.8">
        <vdl-page>
            <vdl-var name="title" value="Portfolio Optimization risky share types"></vdl-var>
            <vdl-var name="rows" value="=scenario.entities.ShareIds"></vdl-var>
            <vdl-section heading="=vars.title">
                <vdl-row>
                    <vdl-column vdl-repeat="=row in vars.rows" heading="=row.value" size="2">
                        <div vdl-text="=scenario.entities.Shares_HighRisk(row.value) && scenario.entities.Shares_fraction(row.value).value ? 'Yes' : 'No'"></div>
                    </vdl-column>
                </vdl-row>
            </vdl-section>
        </vdl-page>
    </vdl>

The `vdl-text` attribute has been assigned a ternary guard expression to ensure the value is set. The `<vdl-var>` elements are positioned outside the `<vdl-page>` element to enable global scope.

This renders as:
Figure : 1. Rendered Global Dynamic Variables
A dynamic variable that is scoped across just the scenario must contain an attribute that identifies its parent scenario by index. The following, changed code snippet illustrates the principle:
View Designer

    <vdl version="5.8">
        <vdl-page>
            <vdl-section>
                <vdl-row>
                    <vdl-column vdl-repeat="=s,i in scenarios">
                        <vdl-var name="title" value="='Portfolio Optimization scenario: ' + s.props.name" scenario="=i"></vdl-var>
                        <span vdl-text="=s.vars.title"></span>
                    </vdl-column>
                </vdl-row>
            </vdl-section>
        </vdl-page>
    </vdl>

The scenario index in the preceding example is captured in the `<vdl-repeat>` element as the loop variable `i`, which is then used as the scenario index for the `<vdl-var>` element. For more on `vdl-repeat`, see Using Loops with Arrays and Sets.
Parent Topic Using Expressions

© 2001-2026 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.