Reporting on tags is tricky in Insights. Tags do not function like other ticket properties, so it takes special steps to use them in reports. This tip will provide an overview of tag reporting in Insights and how to filter reports by tags. If you are looking for a more basic recipe for reporting on tags, see Reporting on ticket tags in our Support tech notes.
This tip contains the following sections:
About tag reporting
Tags are in a unique, many-to-many relationship with tickets. One tag can be on multiple tickets, and one ticket can contain multiple tags simultaneously. This is different from all other ticket properties. For example, a ticket can only be in one group at a time, but it could have 200 tags.
To manage that many-to-many relationship, tags are treated differently when they are imported into Insights. Instead of simply listing the tags associated with a ticket, a unique ID is created for each ticket/tag combination. This tag data is stored in its own dataset.
This means ticket/tag data is completely separate from other ticket properties, even though they are all associated with ticket ID.
For tag data to function in a report, the metric must have a connection to the special tags dataset. The default # Tickets metric below already does this:
- SELECT COUNT(Ticket Id, TicketTagId) WHERE Ticket Status <> Deleted AND Ticket Tag Deleted Flag <> true
For contrast, look at the default Full Resolution Time (min) [Mdn] metric below:
- SELECT MEDIAN(Full resolution time in minutes) WHERE Ticket Status <> Deleted
This metric has no connection to ticket tag data. If you use this default metric in your report, it will ignore any filters based on ticket tags.
If you want to report on tags consistently, you'll need to take a few extra steps (see Filtering reports by ticket tags).
Using custom fields as an alternative to tag reporting
Before jumping in, ask yourself if there is an easier method to get the same result. For some tags and workflows, it might be more effective to use a custom field rather than a tag.
For example, if you receive tickets from region 1, region 2, or region 3. One way to track this is to automatically add "region1," "region2," and "region3" tags when a ticket is created. That works well in Zendesk business rules, but it makes reporting more difficult. Since a ticket can only come from one region, you can create a custom drop-down field for it. You can then report on fields rather than tags.
Reports using custom fields are easier to filter. You can just use the field attribute, instead of going through all the required steps to report on ticket tags.
For more information see, Reporting on custom fields in Insights.
Filtering reports by ticket tags
As described before, tag data won't function in a report unless the metric connects to the tags dataset. The default # Tickets metric does this, but most other metrics do not connect. Rather than customizing all your metrics, you can build tag filters using the # Tickets metric, even if you don't need to use that metric in your final report. For information on user and organization tags, see Reporting on user and organization tags in our support tech notes.
Step 1: Create metrics for each tag
To create metrics for tags:
- Enter in the following formula:
- SELECT IFNULL((SELECT # Tickets WHERE Ticket Tag = your_tag),0)
- Substitute your_tag with your desired tag.
This metric does two things. The inner part of the metric uses the default # Tickets metric to count all tickets with a certain tag. The outer part of the metric ("IFNULL ... 0") means that tickets without the tag are counted as 0 instead of null.
Please note, you can't just copy and paste in the metric editor. You need to select the items below from the Elements drop-down list:
- # Tickets is under Metrics
- Ticket Tag is under Attributes>Ticket Tags
- your_tag is under Attribute Values>Ticket Tags>Ticket Tag
If you want these custom metrics to be available for any report, check the Add to Global Metrics box.
Below are the custom metrics for VIP tickets that have not merged:
Step 2: Create numeric range filters
After you create your metrics, you can use them to filter your report. If you do not want to use numeric range filters to filter your report see, Adding tag filters within a custom metric.
To filter your report with custom metrics:
- Select the Filter panel.
- Select Numeric Range Filter.
- Under Select Attribute, select Ticket Id.
- Under Select Metric, select one of the custom metrics you created above.
- For the Range, set the drop-down to "is equal to."
- Enter a value of 1 or 0.
- If the metric is equal to 1, the report will only include tickets that have the tag.
- If the metric is equal to 0, the report will only include tickets that do not have the tag.
For this example report, tickets should have the "vip" tag, so the numeric range filter for the "vip" metric is set to equal 1.
For this example, tickets should not have the "closed_by_merge" tag, so the numeric range filter for the "closed_by_merge" metric is set to equal 0.
Step 3: Build your report as normal
After you add your filters, you can remove the custom metrics from your report. As long as the report is looking at ticket data, the filters should keep working.
This example is reporting on the full resolution time, using the default Full Resolution Time (min) [Mdn] metric under What.
The image below demonstrates a full resolution time without any filters:
With the filters in place, only the VIP tickets that have not merged will be included in the report. The image below demonstrates the change in results:
Adding tag filters within a custom metric
These numeric range filters will apply to the whole report, but that is not always ideal. For example, you might want to compare the VIP resolution time above to the overall resolution time. With report-level filters, you can't see both numbers in the same report at the same time.
In cases like this, you would need to build a new metric that includes the tag filter(s). This will vary a bit, depending on the metric. However, the tag filtering portion should look like this:
- SELECT metric WHERE (SELECT # Tickets with your_tag BY Ticket Id)=1
This piece does the same thing as the numeric range filter, but it works within a larger metric. That way, you can filter each metric individually.
In the example below, the "vip" and "closed_by_merge" tag filters have been combined with the Full Resolution Time metric:
Since the tag filters are built into the metric, the numeric range filters can be removed from the Filter panel of the report. This enables you to compare metrics with different filters.
For example, the image below shows the VIP resolution time and overall resolution time in the same chart with no filters:
When it comes to reporting, ticket tags are certainly complex. They have their own spot in the data model with complicated architecture to maintain their unique relationships.
Fortunately, the hard work is already done. After you create these metrics, you can apply them to any ticket-based report.