# Launched: Change Dimension/Metric via Dashboard Filter (by using AQL and Query Parameters)

**URL:** <https://community.holistics.io/t/launched-change-dimension-metric-via-dashboard-filter-by-using-aql-and-query-parameters/2337>\
**Category:** Product Releases\
**Tags:** query-parameter, aql\
**Created:** [December 19, 2024, 8:33am UTC](https://community.holistics.io/t/launched-change-dimension-metric-via-dashboard-filter-by-using-aql-and-query-parameters/2337 "2024-12-19T08:33:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Khai\_To](https://community.holistics.io/user_avatar/community.holistics.io/khai_to/32/128_2.png) [@Khai\_To](https://community.holistics.io/u/Khai_To)\
**Post date:** [December 19, 2024, 8:33am UTC](https://community.holistics.io/t/launched-change-dimension-metric-via-dashboard-filter-by-using-aql-and-query-parameters/2337/1 "2024-12-19T08:33:42Z")

</div>

# Introduction

AQL is getting an upgrade! No more static calculations. You can now make AQL dynamic by combining it with [Query Parameters](https://docs.holistics.io/docs/query-parameters).

This means AQL definitions can adjust based on user inputs via the Dashboard Filter, and you’ll be able to do **Dynamic fields selection (dynamic dimensions, dynamic metrics)**

# Demo

## Dynamic Dimension selection

### How to set up

[https://cdn.holistics.io/product/aql-dynamic-dim-selection-20241219-507.mp4](https://cdn.holistics.io/product/aql-dynamic-dim-selection-20241219-507.mp4)

In the video, you want your metric to be dynamically broken down by Countries, Cities, and Genders

First, create a Query Parameter in the model. Then, use AQL to create a Dimension that dynamically switches based on the user’s selection through a Dashboard filter.

```typescript
Model dynamic_model {
  
  dimension country_name { }
  dimension city_name { }
  dimension gender { }
  
  param dim_choice {
    label: 'Dim Choice'
    type: 'text'
    allowed_values: ['Countries', 'Cities', 'Gender']
  }

  dimension dynamic_dim {
    label: 'Dynamic Dim'
    type: 'text'
    definition: @aql case(
      when: 'Countries' in dynamic_dim_model.dim_choice
      , then: dynamic_dim_model.country_name
      , when: 'Cities' in dynamic_dim_model.dim_choice
      , then: dynamic_dim_model.city_name
      , when: 'Gender' in dynamic_dim_model.dim_choice
      , then: dynamic_dim_model.gender
    ) ;;
  }
}

```

## Dynamic Metrics selection

### How to set up

[https://cdn.holistics.io/product/aql-dynamic-metrics-selection-20241217-503.mp4](https://cdn.holistics.io/product/aql-dynamic-metrics-selection-20241217-503.mp4)

Similar to dynamic dimension selection, you can also use Query Parameters to switch the metrics displayed in the visualization.

```typescript

Model param_model { 
  param metric_selection {
    label: 'Metric Selection'
    type: 'text'
    allowed_values: ['Revenue', 'Total Orders', 'Total Users']
  }
}

Dataset ecommerce {

  models: [your_models, param_model]
  relationships: []

  metric revenue {
    label: 'Revenue'
    type: 'number'
    definition: @aql sum(order_items, order_items.quantity * products.price) ;;
  }

  metric total_orders {
    label: 'Total Orders'
    type: 'number'
    definition: @aql count(orders.id) ;;
  }

  metric total_users {
    label: 'Total Users'
    type: 'number'
    definition: @aql count(users.id) ;;
  }

  metric dynamic_metric {
    label: 'Dynamic Metric'
    type: 'number'
    definition: @aql
      case(
        when: 'Revenue' in param_model.metric_selection
        , then: revenue
        , when: 'Total Orders' in param_model.metric_selection
        , then: total_orders
        , when: 'Total Users' in param_model.metric_selection
        , then: total_users
      )
     ;;
  }
} 

```
