Make an action conditional (Beta)

🚩

This documentation describes a public beta feature and is under construction. This documentation should not be considered part of our published documentation until this notice, and the corresponding Beta flag on the feature in Sigma, are removed. As with any beta feature, the feature discussed below is subject to quick, iterative changes. The latest experience in the Sigma service may differ from the contents of this document.

Beta features are subject to the disclaimer on Beta features.

You can define an optional condition for any action to control the circumstances in which the action should take effect. The condition can be a custom formula or, if you are configuring an action for selected controls, the condition can be the value of the control. For more information about actions in Sigma, see Intro to actions.

To make an action conditional, turn on the Condition toggle when creating or editing the action.

📘

Custom formulas for conditions do not support user selection of a specific cell in a table.

You can configure multiple actions, each with an optional condition. If a user interacts with an element that has multiple actions configured, each action effect occurs if its condition, if there is one, evaluates to true.

Example: Modify a chart display based on a segmented control

You can configure an action on a segmented control that modifies the display of a visualization based on the value the user selects in the control. For more about using segmented controls, see Create and configure a segmented control.

For example, if you have a chart showing the total sales, broken down by region, you can add a segmented control to allow users to change the display of the chart to their preferred view.

To achieve this, follow these steps:

  1. Add a segmented control targeting your visualization, giving it two values: Individual trend and Comparison.

  2. Add an action on the control with the following configuration:

    ConditionTurn on the toggle and set to Control value is equal to. For this example, select Individual trend.
    ActionSelect Modify element.
    Target elementSelect the visualization targeted by the control. In this example, the visualization is Total sales by country over time.
    What to modifySelect a modification to display the chart in a way that matches the user selection in the control. In this example, the modification is Move columns and to trellis column.
    Column to moveIn this example, the column is Country.

    Action configuration modal showing the values configured with a condition on the control value being Individual trend. The remaining values configure the action to modify the visualization element to move the Country column to trellis column.

  3. Add a second action on the control with the following configuration:

    ConditionTurn on the toggle and set to Control value is equal to. For this example, select Comparison.
    ActionSelect Modify element.
    Target elementSelect the visualization targeted by the control. In this example, the visualization is Total sales by country over time.
    What to modifySelect a modification to display the chart in a way that matches the user selection in the control. In this example, the modification is Move columns and to color - category.
    Column to moveIn this example, the column is Country.

    Action configuration modal showing the values configured with a condition on the control value being Comparison. The remaining values configure the action to modify the visualization element to move the Country column to color - category.

  4. You now have two actions configured on your segmented control, each one modifying your visualization element based on the value of the segmented control.

    List of two Modify element actions configured on a segmented control.

  5. Publish your changes to the workbook.

When viewers interact with the control, they can now swap back and forth between the individual trend and comparison view of the data in your visualization.

GIF showing a visualization of Total sales by country over time and a control with two values, Individual trend and Comparison. In the animation, a user clicks each of the two values, demonstrating that the chart visualization switches between a trellis view of each country and a combined view in a stacked bar chart.

Example: Limit form submissions with a deadline

You can configure a condition on an action to prevent it from occurring if a deadline has passed.

For example, if you are creating a form, you can configure the action on the submission button to insert a row in an input table only if the deadline has not yet passed. For more information about actions that insert rows in input tables, see Create actions that modify input table data (Beta).

To achieve this, follow these steps:

  1. Create a workbook with an empty input table, one or more text controls, and a button element.

  2. Configure the input table data entry permissions to allow edits in Published mode. See Configure data governance options in input tables for details on how to modify data entry permissions.

  3. Add another control of any type to the workbook, then open the Element properties panel and set the Control type to Date. In this example, the date control has a control ID of Deadline-Control.

  4. Set a date in your date control to a future date. This date is used as the deadline when you set the condition.

  5. Select the button element, then click Actions.

  6. Add an action with the following configuration:

    ConditionTurn on the toggle and set to Custom formula. For this example, enter DateDiff("day", Today(), [Deadline-Control]) > 0 . This formula evaluates to True if the number of days between the current date and the date set in the date control with the ID "Deadline-Control" is greater than zero.
    ActionSelect Insert row.
    IntoSelect the name of your input table. In this example, the name is Form Submissions.
    With valuesSelect the control elements that make up your form.

    Action configuration modal showing a condition defined by a custom formula. The remaining values configure the action to insert a row in a table using the values of text controls.

  7. Publish your workbook, then view your workbook in Published mode

  8. Test your action by entering text in the text controls, then clicking the button.

    1. If the date in your date control is set to a date later than today's date, the values of your text controls should appear as new rows in your input table.
    2. If you update the date in your date control to today's date or any past date, clicking the button does not insert a row, because the deadline has passed.