If you are creating Insights reports that do not include pre-made elements, you might need to build a custom metric. You can write MAQL (Multi-Dimension Analytical Query Language) in Insights' Advanced Metric Editor to create custom metrics.
This tip provides an overview of building your own custom metrics. For more in-depth information on using the Advanced Metric Editor, see GoodData's documentation Get Started with Using MAQL to Write Metrics. For additional resources on using Insights, see Insights resources (Professional and Enterprise) .
This tip contains the following sections:
Navigating to the Advanced Metric Editor
This section will discuss how to open the Advanced Metric Editor in GoodData.
- Click the Reporting icon (
) in the agent interface, then open the Insights tab.
- Click the GoodData link in the upper right corner.
- Click Reports .
- Click Create Report .
- In the What menu, click the (advanced) link next to Add new metric .
- Select Custom metric .
You will now be redirected to the Advanced Metric Editor.
Writing custom metrics
This section will discuss how to enter formulas in the Advanced Metric Editor. After you click Custom metric , you will be redirected to the Advanced Metric Editor as shown below.
- Enter a name for your metric in the Name your metric text box.
- Check the Add to Global Metrics box to access your metric in any of your reports. If you want the metric to only be available in the current report, leave unchecked.
If you check Add to Global Metrics , choose a folder to store the metric in. You can then edit the format of your metric in the Format string box. You can define the number of decimal places or add a % suffix to format the metric as a percentage.
- Enter your MAQL formula into the Editor pane directly below Add to Global Metrics . If you are not familiar with writing MAQL in the Editor pane, see Using the Editor pane below.
- Click Add .
Using the Editor pane
In the Editor pane, you can write your MAQL to build your custom metric. All metrics begin with SELECT.
Below the Editor pane, there is a list of functions you can apply to the facts, metrics, and attributes in your metric. Each function contains a definition, and you can click on a function to add it to your report.
You cannot directly type in your facts, metrics, and attributes, but instead must select from the Elements menu.
The Elements menu contains the following folders:
- Facts: Raw numbers from your data
- Metrics: Existing queries
-
Attributes: Date fields and text fields
-
Attribute Values: A choice for an attribute. For example, the attribute Color could contain attribute values such as Red, Green, or Blue.
-
Attribute Labels: The name of the attribute field. In the example above the label would be "Color".
-
Variables: These permit metrics to be dynamic, based on the user who is viewing the metric.
Once an element is added to the custom metric formula, it will automatically be color coded. Facts will be blue, metrics will be green, attributes and attribute labels will be purple, attribute values will be orange, and variables will be light brown.
For a full list of Zendesk Insights metrics and objects, see Insights metrics reference and Insights objects reference
To add an element to your report
- Click on the folder containing the element you would like to add.
- Choose the element or elements to add.
- Click the + Add Selected button at the top of the panel or double-click the element.
Avoiding common mistakes
Below are some common mistakes users make when creating custom metrics and how to avoid them.
When creating custom metrics, one common mistake is copying and pasting formulas directly from a plain-text document. For a custom metric to work, you must choose your metrics and attributes from the Elements panel. Typing out element names or copying and pasting from a different source will not be successful.
The image below displays a copied and pasted formula. This formula is incorrect.
The image below displays a formula that uses the Elements menu to add objects. This formula is correct.
Another common mistake is missing matching parentheses. If you are creating a query that is more complicated than a single aggregated action, you should be careful with your parentheses and make sure that sub-queries are properly nested. If your query contains any missing parentheses, it will be incorrectly interpreted. If you are creating a complicated custom metric, it might be easier to break your custom metrics into pieces.
The last common mistake for creating your custom metrics is syntax errors. If you receive a red error message when clicking the Add button at the bottom of the editor, you might need to check your syntax for any extra characters and spaces, missing parentheses, or incorrect elements. For example, extra hashtags or misplaced commas are common mistakes. Before submitting and saving your metric, you should carefully double check your syntax, look for extra characters and spaces, make sure you have the right parentheses, and have chosen the proper values from the right hand side.
For some examples of sample reports, see Insights recipes reference . You can use these recipes as practice for building and replicating custom metrics. For definitions of all available Insights elements, see Insights objects reference and Insights metrics reference .
21 Comments
Can you query two facts at the same time? In normal SQL it would look similar to this + some ORDER BY

I want to query top 10 users asking for support and the amount of tickets they created. Any advice?
Hey Christian -
I would suggest re-posting your question in the Insights Q&A topic in the Community. A lot more users frequent that area and you may have better luck getting an answer over there.
Thanks, just did. I am under time pressure and I'm afraid I will not receive any help in that section.
Hello,
I actually asked my question under another article, but it seems like this is where I should have asked. I created custom metrics for tags to be able to see how many tickets have been tagged with the different tags. I made two mistakes which I need to fix in each one. How can I edit them? I tried to find it, but couldn't.
The first mistake is that I used "0" instead of "1".
SELECT IFNULL((SELECT # Tickets (GRÖNT) WHERE Ticket Tag (LILA) = your_tag(ORANGE)),0)
The second mistake is that I didn't make them Globa.
Thanks in advance!
Sorry, this is what I used:
SELECT IFNULL((SELECT # Tickets WHERE Ticket Tag) = your_tag(ORANGE)),0)
Hi Chrisa!
I'm going to check with some of our Insights experts to see if we can find an answer on this for you!
Hi Chrisa!
You can find a list of your metrics, including links to edit them, on the Manage > Metrics page in the GoodData interface. Start by opening the GoodData interface from the "GoodData" link in the top right corner of the Insights tab in Zendesk Support.
Once GoodData is open, select "Manage" from the menu bar at the top of the page, and "Metrics" from the left sidebar:
You should be able to locate your metrics from here.
Hello,
Is anyone else redirected to the "Attributes" elements list when they click "Attribute Values" or "Attribute Labels"? I am not able to create a new metric through the editor because I can't get to the elements "Agent", "Admin" and "true", which should all be in the "attribute values" section.
Any help would be greatly appreciated :)
Hi Sofia! Welcome to the Community!
I'm going to see if I can get an Insights expert in here to help you out. Stand by!
Hi Sofia,
Sorry to hear that you're experiencing issues when trying to create your custom metrics! As this may be account specific, I'm going to reach out to you via a ticket to do some more advanced troubleshooting. You'll hear from me again soon! :)
Best,
Amanda
Customer Advocate | Zendesk
Hello!
Does anyone know how can I create a metric that track Solved Tickets on the same day they were created and another one to track Solved Tickets of past days ?
Regards,
Carla, check the following link out:
https://support.zendesk.com/hc/en-us/community/posts/115000613908-Developing-a-Report-for-Agent-Productivity-and-Interactions-?page=1#community_comment_360001279307
Thanks for jumping in, David!
Can I create a metric that results me the top 10 words or phrases written on the chats?
Hello Everyone,
I'm trying to make a custom metric that shows me how long a ticket had each particular status, ie - how long was it open, how long was it On-Hold, how long was it Pending? We're trying to get to resolution time, but being able to break it out into Open (which is our support team) and On-Hold (which is our engineering team) and the two together = a full resolution. We also tend to move things to Pending once a ticket is solved, but we would like the customer to confirm resolution. We don't want that pending time to count against the resolution time.
I've attempted to make this report:
I am using a custom metric with the formula SELECT AVG([TEXT FIELD] Duration in Minutes /60) BY Ticket Status (Historic) Where Ticket Status <> DELETED.
Under HOW, I'm using Ticket Status (Historic):
I want to make sure that I'm not pulling in Average time based on the current ticket status. Have I done this correctly?
Thank you!
Tiffany
This is a little easier. Zendesk provide native time metrics in Insights. So, you do not need to recreate the values from the field duration.
You can create a new metric for you team to remove the on hold time from Requester Wait. Your Support Team time in hours will be:
To create your metric, you will find the requester wait time and on hold time in the 'Facts' element on the selection menu on the right hand side.
For these metrics to work, ensure you filter your report for Solved and Closed ticket status.
Ok, after reading I found out that I can create a custom attribute by creating a ticket field. Once the data for that field is in, Zendesk will import the ticket field as an attribute or fact depending on the ticket field type.
My question, can I asked a users to choose the value of this custom ticket field when a ticket is solved/closed? Kinda like how the satisfaction rating survey work, the user will receive and email that say something like
Hey, please choose one of this button to blablabla.
The users will be presented with two button and when they click one of them zendesk will assign a value to the custom ticket field that I create earlier.
Thank you Graeme. I will try this today!
@Leonardo if you'd like to provide a button for the user to select you'd most likely need to use some HTML code in your trigger. The other option would be to have the user reply by typing Option A or Option B. You can then set up a trigger that automatically assigns the custom field value based on comment text within the ticket update.
Let me know if you need help setting this up!
@Brett, any article that can help me with creating HTML code in my trigger? Also, the 2nd option that you mentioned might be a little bit difficult since you know how user are :). But hey, beggars can be choser so I would appreciate if you can help me on the right direction with that one too, at least as an alternative if the HTML trigger is not working.
Hey Leonardo,
The only relatively close article I could find is here: Building a custom ticket for with Zendesk API
Apologies for not being able to find more relatable documentation for this particular scenario :-/
Please sign in to leave a comment.