Juicebox
Preparing your dataStory DesignerVisual design tips
  • Juicebox Documentation
  • What is Juicebox?
    • Technology requirements
  • Getting Started
    • Getting a Workspace
    • Reach out to us
  • Building Reports
    • Creating and Editing Reports
    • Data
      • Loading data
      • Managing data
      • The data preview
    • Design
      • Slices
        • Dynamic text
        • Customizing what shows
        • Multiple data tables
        • Charts
          • Headline
          • Filters
          • Chooser
          • Table
          • Card
          • Reports Navigation
          • Bar
          • Scatterplot
          • Leaderboard
          • Map
          • Trend
          • Pie
        • Selections as Variables
        • Debug
      • Ingredients
        • The ingredient editor
          • The dimension ingredient editor
          • The measure ingredient editor
        • Adding new ingredients
        • Advanced field formulas
        • Time formats
        • Number formats
    • Share
      • Publishing a report (or report changes)
      • Inviting viewers
      • Insights
    • Tips and Tricks
      • Telling data stories
      • Visual design
      • Preparing your data
      • Useful resources
  • Viewing Reports
    • Signing In
    • Navigating Reports
    • Focus and Filter
  • Managing Users
    • Adding Users
    • User Roles and Management
    • Limiting what data users can see
    • Access Views
    • Embedding Juicebox Apps
      • How embedding works
      • Juicebox Embedding API
      • Juicebox API
    • Requesting data from embedded apps
  • Managing my workspace
    • Workspace Settings
    • Subscription and Billing
  • Changelog 🎁
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. Building Reports
  2. Design
  3. Slices

Selections as Variables

Slice selections don't always have to filter down the page

PreviousPieNextDebug

Last updated 1 month ago

Was this helpful?

By default, selections in a slice filter the data in downstream slices. You can change this default behavior by configuring slice selections.

You can configure the slice selections to act as:

  1. Filters. Slice selections will filter downstream slices. (This is the default configuration.)

  2. Variables. Slice selections will not filter downstream slices but will be available for use in defining ingredients.

  3. Filters and Variables. Slices selections will filter downstream slices and be available for use in defining ingredients.

How to use Variables

If you configure slice selections to act as Variables, the selected values will be saved. You can use the saved values in ingredient definitions. For example, let's say you have a Filter slice with two dimesions: Genres and Directors.

Using variables in your ingredients labels

You can use variables to make dynamic ingredient labels. To start you need to know the ingredient id of the selected variable. You can open the ingredient and click the "..." and select "Copy Ingredient Id".

Use the id of the ingredient being used as a variable in the label by surrounding it with brackets like this “{{ingredient_id}}“. You can also other text in your label too, so "Budget of {{Director}}" would work if an ingredient with id of Director was a variable.The variable must be selected above. Otherwise you'll just get the label without the variable substituted.

Using variables in your ingredient's field expressions

You can use variables in your field definition. For instance, if you have selected a director in a variable, you can refer to the selected director in your field like this: field:

sum(if(Director="{{Director}}", Budget, 0))

Note the double quotes around {{Director}} because it's a string.

Using variables to define constants

You can use variables in your datasource constants. Just refer to the variable to get the first movie released by the selected director.firstMovieReleaseDate: min(if(Director="{{Director}}", ReleaseDate))

Limitations

Here are two things to keep in mind. We plan on improving these later.

  • We only substitute variables in fields, singular, and plural for ingredients. We aren't substituting in buckets. We are substituting in optional fields like id_field or latitude_field.

  • The variable is the first selected value. If you have multiple values selected, only the first will be available.

​