We have a lookml which uses a constant name for a project ..
lookml sql code -
sel * from @project.table
just trying to see how I can parameterize/override the default with user input?
I want to keep the default as is, but enhance the dashboard to accept user project value at runtime and run the sql for new project ..
You can do this by creating a Looker Parameter that has each project listed as an option (this will avoid user typo’s). Below is an example where I created a view that allows users to select the table at runtime. The Parameter will be displayed in the Explore as a Filter only Field, and the options available in the pull down will be those you specify.
view: filter_test {
derived_table: {
sql:
SELECT
m_number
FROM {{ _user_attributes['datalake_project'] }}.xxxx_consumption_layer.{% parameter table %}
GROUP BY 1
;;
}
I have thoughts of trying this out, but this will be a dimension. Can I use this dimension as a parameter?
I want to pass the parameter as input upon which rest of the code will run
I’m not sure what you mean by it being a dimension. Can you provide some example code of what you are doing now?
Parameters manifest like filters in the UI. So you can provide them values to define what they should be (e.g., what table) and then they’ll change how your code works. If you set this as a dimension, you have no way of changing the value for the query that is run. In the explore UI, you can check the SQL that Looker generates before a query is run to watch how Looker interprets your coding.