Selections as Variables
Slice selections don't always have to filter down the page
Last updated
Was this helpful?
Slice selections don't always have to filter down the page
Last updated
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:
Filters. Slice selections will filter downstream slices. (This is the default configuration.)
Variables. Slice selections will not filter downstream slices but will be available for use in defining ingredients.
Filters and Variables. Slices selections will filter downstream slices and be available for use in defining ingredients.
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.
If you have an advanced ingredient 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, I have to surround the {{Director}} with double quotes because it's a string.
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))
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.
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.