# Dynamic Metrics Selection > Learn how to create measures that adapt based on context or user input :::tip knowledge checkpoint A grasp of these concepts will help you understand this documentation better: - [Parameter Fields](/docs/modeling/param-fields) - [AQL Expression](/reference/aql/expression) - [Measure](/docs/model-fields#measures) ::: ## Introduction Using [param fields](/docs/modeling/param-fields), we can build charts with dropdown that allow users to change the metric dynamically. ## Dynamic Metrics Selection ![Dynamic Metrics Selection](https://media.holistics.io/pvlqaz-dynamic-metric-switch.png) Assuming that you have a model with 3 metrics: `total_orders`, `revenue`, and `total_users`. You want to build a dashboard that let user pick which measure to be used in your report. ```typescript Model sales_model { measure total_orders { } measure revenue { } measure total_users { } } ``` This can be implemented using [Parameter Field](/docs/modeling/param-fields) and [AQL Expression](/reference/aql/expression) ### Step 1: Create a Parameter Field First, create a [Parameter Field](/docs/modeling/param-fields) in the model. ```typescript Model sales_model { measure total_orders { } measure revenue { } measure total_users { } //highlight-start param metric_selector { label: 'Metric Selector' type: 'text' allowed_values: ['Total Orders', 'Revenue', 'Total Users'] } //highlight-end } ``` ### Step 2: Create a Dynamic Metric field Create a Dynamic Metric that changes based on the selected parameter value. ```ts Model sales_model { measure total_orders { } measure revenue { } measure total_users { } param metric_selector { } //highlight-start measure dynamic_metric { definition: @aql case( when: 'Total Orders' in sales_model.measure_selector , then: sales_model.total_orders , when: 'Revenue' in sales_model.measure_selector , then: sales_model.revenue , when: 'Total Users' in sales_model.measure_selector , then: sales_model.total_users ) ;; } //highlight-end } ``` ### Step 3: Use `Dynamic Metrics` in the report In the report, you can use `Dynamic Metrics` with another dimension. ### Step 4: Use Parameter Field in the dashboard filter In the dashboard filter, you can use `Measure Selector` Parameter Field to dynamically choose which measure to use in the report. ## Advanced: Metrics selection at Dataset level If your metrics are defined at the dataset level, we recommend **creating a dedicated model to store your parameter fields**. While you can technically place parameter fields in any existing model, having a dedicated model gives you a single, predictable place to manage them. 1. **Create a separate model to contain the `param`** ```tsx Model param_model { type: 'query' // can be either `table` or `query` model query: @sql select 1 ;; // Dummy query //highlight-start param metric_selector { label: 'Metric Selector' type: 'text' allowed_values: ['Revenue', 'Total Orders', 'Total Users'] } //highlight-end } ``` 2. **Add the `param_model` to the Dataset and define the `dynamic_metrics` at the dataset level** ```tsx Dataset ecommerce { //highlight-next-line models: [countries, cities, users, orders, param_model] relationships: [ ] metric revenue { } metric total_orders { } metric total_users { } //highlight-start metric dynamic_metrics { label: 'Dynamic Metrics' type: 'number' definition: @aql case( when: 'Revenue' in param_model.metric_selector , then: revenue , when: 'Total Orders' in param_model.metric_selector , then: total_orders , when: 'Total Users' in param_model.metric_selector , then: total_users ) ;; } //highlight-end } ```