# How to model drill-across relationships?

**URL:** <https://community.holistics.io/t/how-to-model-drill-across-relationships/1276>\
**Category:** Ask the Community\
**Created:** [November 3, 2022, 11:50pm UTC](https://community.holistics.io/t/how-to-model-drill-across-relationships/1276 "2022-11-03T23:50:43Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![tan](https://community.holistics.io/user_avatar/community.holistics.io/tan/32/358_2.png) [@tan](https://community.holistics.io/u/tan)\
**Post date:** [August 30, 2023, 4:11am UTC](https://community.holistics.io/t/how-to-model-drill-across-relationships/1276/13 "2023-08-30T04:11:38Z")

</div>

Yes, I’m been waiting to share the progress on this, but the documentation is not there yet.

But I can tell you that we have a way to support these scenarios in the new [AQL engine for 4.0](https://community2.holistics.io/t/upcoming-our-brand-new-analytics-query-language-aql/1533/13).

The gist of the unreleased documentation is that we will support the new `with_relationships` function that allows you to choose the relationships at the metric/expression level. Here is an example of it in action:

```auto
Dataset ecommerce_aql {
  __engine__ : 'aql'
  data_source_name: 'demodb'

  models: [
    users,
    orders,
    dim_dates,
  ]

  relationships: [
    relationship(users.sign_up_date > dim_dates.date_key, true),
    relationship(orders.created_date > dim_dates.date_key, false),
    // This is enabled by default, which means by default orders are retrieved 
    // through users
    relationship(orders.user_id > users.id, true),
  ]

  owner: 'khai.to@holistics.io'

  metric total_orders_by_date {
    description: '''
      This metric counts the number of orders created in a period. 
      If you want the orders created by users, please use the default count(orders.id)
    '''
    label: 'Total Orders By Date'
    type: 'number'
    definition: @aql count(orders.id) | with_relationships(orders.created_date > dim_dates.date_key) ;;
  }
}

```

 ![CleanShot 2023-08-30 at 10.58.56](https://community.holistics.io/uploads/default/original/2X/4/460e80514603a17abf361329704a40621fc9a04e.png)

---

_[View the full topic](https://community.holistics.io/t/how-to-model-drill-across-relationships/1276)._
