What you'll need
Skill level: Advanced
Time Required: 30 minutes
- Zendesk Explore Professional or Enterprise
- Editor or Admin permissions (see Adding users to Explore)
- Ticket data in Zendesk Support
This recipe contains the following attributes:
Proper case ticket tags
This attribute will format ticket tags in the proper case and replace any underscores with spaces.
- In Explore, click the query (
) icon.
- In the Queries library, click New query.
- On the Choose a dataset page, click Support > Tickets > Support: Tickets, then click New query. Query builder opens.
- In the calculations menu (
), click Standard calculated attribute.
- On the Standard calculated attribute page, give your attribute a name like Proper case ticket tags.
- In the formula field, enter or paste the following formula:
REGEXP_REPLACE(REPLACE([Ticket tags],"_"," "),"^[a-z]", UPPERCASE(REGEXP_EXTRACT(REPLACE([Ticket tags],"_"," "),"^[a-z]")))
- Click Save.
Check out an example query below:
Remove start of ticket tag
When creating custom drop-down ticket fields, it is best practice to create a consistent naming convention for the tag values so they all start with the same string. When a drop-down value is deleted, the tag persists on closed tickets. By maintaining a consistent string, you're able to consolidate historical reporting by looking for tickets with tags containing that string.
Check out Best practices for altering your custom ticket fields for more information on deleting values in custom drop-down fields.
Below you'll create a custom attribute to format the tags so the starting string is removed and the tags are changed to the proper case.
- In Explore, click the query (
) icon.
- In the Queries library, click New query.
- On the Choose a dataset page, click Support > Tickets > Support: Tickets, then click New query. Query builder opens.
- In the calculations menu (
), click Standard calculated attribute.
- On the Standard calculated attribute page, give your attribute a name to reflect the tags that are being surfaced. In this example, the attribute is called Retail ticket tags.
- In the formula field, enter or paste the following formula:
IF CONTAINS([Ticket tags], "STRING") THEN REGEXP_REPLACE(REPLACE(RIGHTPART([Ticket tags],LENGTH([Ticket tags])-#),"_"," "),"^[a-z]",UPPERCASE(REGEXP_EXTRACT(REPLACE(RIGHTPART([Ticket tags],LENGTH([Ticket tags])-#),"_"," "),"^[a-z]"))) ENDIF
- Replace some parts of this formula to match the tags that this attribute is meant to surface. Replace STRING with the start of the tag that you are wanting to remove. In this example, STRING is replaced with 'retail'.
- Replace # with the number of characters in the string. In the example, 'retail_' is being removed so the number of characters is 7. See the example completed formula below.
IF CONTAINS([Ticket tags], "retail") THEN REGEXP_REPLACE(REPLACE(RIGHTPART([Ticket tags],LENGTH([Ticket tags])-7),"_"," "),"^[a-z]",UPPERCASE(REGEXP_EXTRACT(REPLACE(RIGHTPART([Ticket tags],LENGTH([Ticket tags])-7),"_"," "),"^[a-z]"))) ENDIF
- Click Save.
Check out an example query below:
Check out Reporting with tags for more tag-based queries.
1 Comments
This will prove to be super handy thanks Jess.
Is there a way that I could remove all characters leading up to the first _ without specifying the string and number of characters?
So I wouldn't have to created a custom attribute for each tag if I had multiple tags per ticket -hopefully that makes sense.
Many thanks.
Please sign in to leave a comment.