Skip to content

Commit 896156b

Browse files
docs: Update passing-dynamic-parameters-in-a-query.mdx (#8381)
Summarizing the approach for easier understanding (it took me a while to understand this wild pattern!)
1 parent 4e530f5 commit 896156b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

docs/pages/guides/recipes/data-modeling/passing-dynamic-parameters-in-a-query.mdx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,23 @@ redirect_from:
77

88
## Use case
99

10-
We want to know the ratio between the number of people in a particular city and
10+
In some cases we may want to let a user select a filter value and be able to
11+
use that value in calculations without filtering the entire query.
12+
13+
In this exmaple, we want to know the ratio between the number of people in a particular city and
1114
the total number of women in the country. The user can specify the city for the
1215
filter. The trick is to get the value of the city from the user and use it in
1316
the calculation. In the recipe below, we can learn how to join the data table
1417
with itself and reshape the dataset!
1518

1619
## Data modeling
1720

21+
Essentially what we will be doing is cross joining all city values with the rows in the data table.
22+
This will duplicate each row for every city in the dataset. Then, we will require the user
23+
to choose a city to filter on, and this will bring us back to our original number of rows. What this
24+
gives us is a new column in the dataset with the value that the user chose, which we can reference in our metrics.
25+
In this case, we will use that value to filter a single metric so that we can compare that metric with the whole population.
26+
1827
Let's explore the `users` cube data that contains various information about
1928
users, including city and gender:
2029

0 commit comments

Comments
 (0)