1. Dynamic Dimensions and Measures

Sometimes we don’t want to show all the dimensions and measures in the field picker of an explore but still provide the functionality behind each of them.

This can be achieved by creating a dynamic dimension/measure which lets the user specify what the dimension or measure is from the filter UI. To do this, you first define a parameter field with a set of allowed_value subparameters:

2. Multiple schemas with the same format of data

Another use case is if we have schemas that are identical in structure. This is often encountered when working with GA Premium data, where one can see tables such as myproject:00001.ga_sessions_, myproject:00002.ga_sessions_, myproject:00003.ga_sessions_. The 00001, 00002, 00003 prefixes could represent data for different countries, or for Web vs iOS, etc.

Using a parameter, you can design a dashboard with a filter that lets your users select the country — with a user-friendly name!

If your company has multiple clients, you might store data from your clients, each in their own schema: clienta.users, clientb.users, etc. Using a similar approach to the country example above, you can let an account manager easily choose which client's data to use.

3. Top N items vs. the rest of population

Often people want to find out the top N performing products and compare those with the rest of the products.

Without a parameter, you would have to hardcode certain buckets (e.g. top 5, 10, 20, and so forth.) However, with a parameter we can let the end user determine N and we can label the remainder as Other.

In the context of an ecommerce store, where we want to find out how well the top N products are doing, we would start with a derived table where we rank each product based on the number of sales.

In my case, I need to define dynamically which table from the database to use that I'm doing like shown on the example "2. Multiple schemas with the same format of data".Both tables have almost the same fields, the only difference is one field where it indicates the day (dt) or month (mon) of the transaction. So i need to be able to define dynamically which field to consume depending on the table used.

On the example "1. Dynamic Dimensions and Measures", it shows how to choose between one field or other but when both fields exits on the same table from the database (as the case clase is resolved by the database, if one of the fields does not exits it fails). This is not my case where on each table I have one field or the other (day or month).

I was trying to so something similar to the "if clause" shown on the 4th example (but to use it on the sql section not on html), but it does not works. Getting error "Cannot use "_filters" in SQL."I tried also to omit the step of assigning to a var an use the <% if my_parameter._value == 'month' %} but it always go to the else clause independently of the parameter value selected.