# Ad-hoc Metric AQL

**URL:** <https://community.holistics.io/t/ad-hoc-metric-aql/2046>\
**Category:** Ask the Community\
**Created:** [August 29, 2024, 5:21pm UTC](https://community.holistics.io/t/ad-hoc-metric-aql/2046 "2024-08-29T17:21:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Becca\_Perry](https://community.holistics.io/user_avatar/community.holistics.io/becca_perry/32/1741_2.png) [@Becca\_Perry](https://community.holistics.io/u/Becca_Perry)\
**Post date:** [August 29, 2024, 5:21pm UTC](https://community.holistics.io/t/ad-hoc-metric-aql/2046/1 "2024-08-29T17:21:55Z")

</div>

Hello - I am trying to create a very basic ad-hoc metric with AQL. I am trying to divide two simple dimensions, but I am getting the error posted below.

Each dimension is modeled in a format like this:

dimension demo\_1 {  
label: ‘Demo Value1’  
type: ‘number’  
definition: @sql {{ #SOURCE.demo\_example1 }} ;;  
format: ‘#,###’  
}

AQL like:  
inventory.demo\_1/inventory.demo\_2

Error message:

```auto
AQL Compilation Errors:
Invalid expression. Cannot reference non grouped dimension `inventory.demo_1` since it may refers to multiple values
inventory.available_quantity

Full Explore Query: ...

```

Is this a bug? For now, I will try making the desired ratio a permanent dimension in the model.

---

<div class="post-metadata">

**Author:** ![minhthanh3145](https://community.holistics.io/user_avatar/community.holistics.io/minhthanh3145/32/816_2.png) [@minhthanh3145](https://community.holistics.io/u/minhthanh3145)\
**Post date:** [August 29, 2024, 5:45pm UTC](https://community.holistics.io/t/ad-hoc-metric-aql/2046/2 "2024-08-29T17:45:43Z")

</div>

Hi @Becca_Perry

Thanks for the question. I’m Thomas from Holistics team. Would you able to share with me (or message me privately) more information (screenshots of your AQL & error), the dimensions/metrics you are using in the VizSettings and in the AQL expression?

---

<div class="post-metadata">

**Author:** ![minhthanh3145](https://community.holistics.io/user_avatar/community.holistics.io/minhthanh3145/32/816_2.png) [@minhthanh3145](https://community.holistics.io/u/minhthanh3145)\
**Post date:** [September 3, 2024, 3:01am UTC](https://community.holistics.io/t/ad-hoc-metric-aql/2046/3 "2024-09-03T03:01:52Z")

</div>

Thanks for getting back. I think the issue is because your AQL expression contains `inventory.available_quantity` that is not explicitly dragged into the Table Fields section. Can you go ahead and do that to see if solve the issue?

 ![Screenshot 2024-08-30 at 11.13.24 AM](https://community.holistics.io/uploads/default/original/2X/6/6093034dbd636560e008743eff568af10b8e892d.png)

If you prefer not to have the `inventory.available_quantity` dimension explicitly in your viz/exploration, can you try to create an ad-hoc dimension with the same formula to see if it work?

![aql dim](https://community.holistics.io/uploads/default/original/2X/9/901cce5e730f49a7832b0fce8e66a21a0601d9bf.gif)

Note that if you’re in a Canvas Dashboard, ad-hoc metrics **won’t be persisted to models** (that’s why we distinguish between ad-hoc metrics and regular metrics). If users explore the report though, then they will see that metric, which is expected if the report uses the metric.

---

<div class="post-metadata">

**Author:** ![Becca\_Perry](https://community.holistics.io/user_avatar/community.holistics.io/becca_perry/32/1741_2.png) [@Becca\_Perry](https://community.holistics.io/u/Becca_Perry)\
**Post date:** [September 3, 2024, 7:29pm UTC](https://community.holistics.io/t/ad-hoc-metric-aql/2046/4 "2024-09-03T19:29:31Z")

</div>

Thank you! I struggled with the ad hoc dimensions because I would add them but then not see them anywhere. My colleague pointed out that I would be able to see them if I toggled the setting next to the search bar. Solved it! Now I can make ad hoc measures and dimensions!  
 ![image](https://community.holistics.io/uploads/default/original/2X/d/d79072e23e2836e3b0e7a180499db7dbd8c69479.png)

---

<div class="post-metadata">

**Author:** ![minhthanh3145](https://community.holistics.io/user_avatar/community.holistics.io/minhthanh3145/32/816_2.png) [@minhthanh3145](https://community.holistics.io/u/minhthanh3145)\
**Post date:** [September 4, 2024, 6:18am UTC](https://community.holistics.io/t/ad-hoc-metric-aql/2046/5 "2024-09-04T06:18:55Z")

</div>

Thanks for letting us know about this! If you create an ad-hoc dimension/metric in a Reporting dataset, you’ll see that you’ll be navigated to the default dataset view automatically where you can see the newly created ad-hoc dim/metric. It seems like you are creating ad-hoc dims/metrics within Reporting reports, and there’s an issue with this flow at the moment. Let us take a look and get back to you!
