Writing Explore formulas

<body>
<p id="docs-hc-snippet" style="display: none;">You can create custom metrics and attributes to use in your report that help you present your business data just how you want it. To do this, you'll need to learn how to write formulas. Formulas perform comparisons, calculations, and manipulations on your data, and help you evaluate conditions.</p>
<div class="article-banners">
<div id="docs-wmp-link">
<a href="https://support.zendesk.com/hc/en-us/articles/5411234991258-plan" rel="noopener" target="_blank">What's my plan?</a>
</div>

<div class="article-banner" id="suite_pee">
<table>
<tbody>
<tr>
<td>
<strong>All Suites</strong>
</td>
<td>Professional, Enterprise, or Enterprise Plus</td>
</tr>
</tbody>
</table>
</div>

<div class="article-banner" id="support_with_explore_pe">
<table>
<tbody>
<tr>
<td>
<strong>Support with</strong>
</td>
<td>Explore Professional or Enterprise</td>
</tr>
</tbody>
</table>
</div>

</div>

<div class="body">

<p class="p">You can create custom metrics and attributes to use in your report that help you present your
business data just how you want it. To do this, you'll need to learn how to write formulas.
Formulas perform comparisons, calculations, and manipulations on your data, and help you
evaluate conditions.</p>
<div class="p">This article contains the following sections:<ul class="ul" id="topic_cl4_cbs_bx__ul_emn_lcd_dx">
<li class="li"><a class="xref" href="#topic_xlg_dpx_wtb">Understanding Explore formulas</a></li>
<li class="li"><a class="xref" href="#topic_qxz_mrn_dhb">Creating a formula</a></li>
<li class="li"><a class="xref" href="#topic_l1j_fxn_dhb">Adding metrics and attributes to your formula</a></li>
<li class="li"><a class="xref" href="#topic_a5p_pcd_dx">Adding functions to your formula</a></li>
<li class="li"><a class="xref" href="#topic_jtq_zh4_vyb">Adding comments to your formula</a></li>
</ul>
</div>
<p class="p">For more information about formulas, see <a class="xref" href="https://support.zendesk.com/hc/en-us/articles/4408845804314" target="_blank">Formula writing resources</a>.</p>
</div>
<div aria-labelledby="ariaid-title2" class="topic nested1" id="topic_xlg_dpx_wtb">
<h2 class="title topictitle2" id="ariaid-title2">Understanding Explore formulas</h2>
<div class="body">
<p class="p">Formulas are generally constructed with two pieces: </p>
<ul class="ul" id="topic_xlg_dpx_wtb__ul_hjk_ppx_wtb">
<li class="li">
<strong class="ph b">Metrics and attributes</strong> that contain your Zendesk information </li>
<li class="li">
<strong class="ph b">Functions</strong> that perform operations on those metrics and attributes</li>
</ul>
<p class="p">Formulas in Explore are read from left to right, and follow the mathematical order of
operations. A formula can contain multiple statements, each containing a combination of
metrics, attributes, and functions that are used to define the data you're looking for.</p>
<p class="p">Within a formula, functions, such as IF/THEN, are often contained within parentheses
<code class="ph codeph">()</code>, much like algebra, so that they don't affect the rest of the formula.
If a formula has only one function, parentheses might not be necessary.</p>
<p class="p">Metric and attribute names are contained within brackets <code class="ph codeph">[]</code>. Metric and
attribute values, expressed as text strings, are contained in quotation marks, and must
match the values exactly. For example, "End-user" and "end user" are two different values.
Most values for attributes can be found within the attribute itself. Click an attribute to
see the list of possible values for that attribute. Operators are used to connect attribute
names and values, or to perform additional calculations.</p>
<p class="p">Putting this all together, a simple formula might read as follows:</p>
<p class="p"><img class="image img-screenshot" id="topic_xlg_dpx_wtb__image_wkt_xsx_wtb" src="https://zen-marketing-documentation.s3.amazonaws.com/docs/en/explore_formula_annotated.png"></p>
<div class="p">
<div class="note tip" id="topic_xlg_dpx_wtb__note_vdz_h2s_sxb">
<span class="tiptitle">Tip:</span> Now that you understand the basics of a formula, you
can dig into more advanced information about data types within formulas (see <a class="xref" href="https://support.zendesk.com/hc/en-us/articles/5784398875802" target="_blank">Working with data types in Explore formulas</a>), or continue
reading below to learn how to create a formula in Explore.</div>
</div>
</div>
</div>
<div aria-labelledby="ariaid-title3" class="topic nested1" id="topic_qxz_mrn_dhb">
<h2 class="title topictitle2" id="ariaid-title3">Creating a formula</h2>
<div class="body">
<p class="p">Now that you know that an Explore formula is made up of metrics, attributes, and functions,
you'll learn how to create the example formula above.</p>
<p class="p">It can be helpful to write down the logic of a formula to help you create it and find the
right functions you need. In this case, the formula flow is "If the ticket channel is email,
show me the ticket ID." You'll see later that this is very similar to the formula you'll end
up with.</p>
<p class="p"><strong class="ph b">To create a formula that displays tickets from the email channel</strong></p>
<ol class="ol" id="topic_qxz_mrn_dhb__ol_pf2_ysn_dhb">
<li class="li">In Explore, <a class="xref" href="https://support.zendesk.com/hc/en-us/articles/4408821589530" target="_blank">create a new report</a> or <a class="xref" href="https://support.zendesk.com/hc/en-us/articles/4408823403546" target="_blank">open an existing report for editing</a>.</li>
<li class="li">Open the calculations menu (<img class="image" id="topic_qxz_mrn_dhb__image_ztc_3kq_h1b" src="https://zen-marketing-documentation.s3.amazonaws.com/docs/en/Explore_calculations.png">).<div class="p">
<div class="note important" id="topic_qxz_mrn_dhb__note_pxj_vnv_r5b">
<span class="importanttitle">Important:</span> If two editors are creating or editing
different reports in the same dataset, only the first person who opened a report can
access the Calculations menu. The other editor will see the message “This resource is
locked because it is currently being edited by &lt;name&gt;”. Once the first person
closes the report, the Calculations menu will become available to the next
editor.</div>
</div>
</li>
<li class="li">Click <strong class="ph b">Standard calculated attribute</strong>. A new blank attribute opens.</li>
<li class="li">Enter a name for the attribute like <strong class="ph b">Tickets received by email</strong>.</li>
<li class="li">In the formula window, start entering your formula. There are a number of ways you can
do this, but for now, under functions, click <strong class="ph b">Add</strong>.</li>
<li class="li">Search for <strong class="ph b">IF THEN ELSE Conditional expression</strong>. Either use the search box, click
<strong class="ph b">Filter</strong> to scope the values down to the <strong class="ph b">Logical</strong> category, or scroll through
the list until you find the function you want.</li>
<li class="li">Next to <strong class="ph b">IF THEN ELSE Conditional expression</strong>, click <strong class="ph b">+</strong>.<p class="p">Explore adds a
template IF THEN ELSE formula to the window. The values in the formula shown in blue
(beginning with an _ character) are placeholders that you must replace with the values
you need.</p>
<p class="p"><img alt="Explore template formula" class="image img-screenshot" id="topic_qxz_mrn_dhb__image_xdp_m5n_dhb" src="https://zen-marketing-documentation.s3.amazonaws.com/docs/en/Explore_formula_1.png"></p>
<div class="note tip">
<span class="tiptitle">Tip:</span> Notice the error message prefixed with (<img class="image" id="topic_qxz_mrn_dhb__image_dsz_2vn_dhb" src="https://zen-marketing-documentation.s3.amazonaws.com/docs/en/formula_error_icon.png">) above the formula. This indicates a problem and its location
in the formula. For now, you can ignore the error. It's appearing because your formula
is still using placeholders.</div>
</li>
<li class="li">Next, you'll replace <strong class="ph b">_boolean_condition</strong> with the Explore attribute you want to
test. Either highlight <strong class="ph b">_boolean_condition</strong> and then choose <strong class="ph b">Ticket channel</strong>
from the <strong class="ph b">Fields</strong> menu, or amend the formula manually to add the attribute.</li>
<li class="li">Now, add the rest of the condition. To search for the string "Email", we add that to the
existing condition.<p class="p">Your formula should now read <strong class="ph b">IF ([Ticket channel]="Email") THEN
_value_if_true ELSE _value_if_false ENDIF</strong></p>
</li>
<li class="li">Next, add what you want to do if the condition is true, in this case return the ID of
the ticket. Replace <strong class="ph b">_value_if_true</strong> with <strong class="ph b">[Ticket ID]</strong>. Notice that as you type
<strong class="ph b">[Ticket ID]</strong> that Explore automatically suggests matches to what you are typing.
If the metric or attribute you want is shown, hit return to immediately complete entry of
it.</li>
<li class="li">The ELSE clause shown in the template ticket can be used to provide an alternative
action that will apply if the first condition is not true. In this case, we don't need it,
so remove <strong class="ph b">ELSE _value_if_false</strong>.</li>
<li class="li">You've now completed the formula. If all is well, you'll see something like the screen
below. Additionally. note that the error has gone and is replaced with a green check mark
to indicate that the formula is valid.<p class="p"><img alt="Explore formula example" class="image img-screenshot" id="topic_qxz_mrn_dhb__image_qcs_lwn_dhb" src="https://zen-marketing-documentation.s3.amazonaws.com/docs/en/Explore_formula_2.png"></p>
</li>
<li class="li">Finally, click <strong class="ph b">Save</strong>. The attribute you created can now be accessed by any of your
Explore reports that use the same dataset. You can find it by clicking <strong class="ph b">Add</strong> in any
attribute panel and expanding <strong class="ph b">Calculated attributes</strong>.</li>
</ol>
</div>
</div>
<div aria-labelledby="ariaid-title4" class="topic nested1" id="topic_l1j_fxn_dhb">
<h2 class="title topictitle2" id="ariaid-title4">Adding metrics and attributes to your formula</h2>
<div class="body">
<p class="p">It's likely that most of the formulas you write with Explore will use metrics or attributes
from the dataset you are currently using. In the example above you used the attribute
<strong class="ph b">Ticket channel</strong>, but there are many hundreds more you can choose from.</p>
<p class="p">While it can feel intimidating at first, most of these metrics and attributes have
descriptive names that will help you to find what you need. Also, experiment with creating
basic reports in Explore to learn more about what the various metrics and attributes do.</p>
<p class="p">You can find a full list of all the metrics and attributes you can use in the <a class="xref" href="https://support.zendesk.com/hc/en-us/articles/4408839218842-Zendesk-Explore-metric-and-attribute-reference" target="_blank">Understanding Explore datasets</a>.</p>
<p class="p"><strong class="ph b">To add a metric or attribute to your formula</strong></p>
<ol class="ol" id="topic_l1j_fxn_dhb__ol_cps_4yn_dhb">
<li class="li">In the Explore formula window, click <strong class="ph b">Select a field</strong>.</li>
<li class="li">Either scroll through the list, or type the first few letters of the metric or attribute
you want, to filter the list.<p class="p"><img alt="Explore choose a field list" class="image img-screenshot" id="topic_l1j_fxn_dhb__image_vbq_zyn_dhb" src="https://zen-marketing-documentation.s3.amazonaws.com/docs/en/Explore_formula_3.png"></p>
</li>
<li class="li">Click the metric or attribute you want and it is added to the formula. In this case,
Ticket ID was chosen. Note how it is surrounded with brackets [].<p class="p"><img alt="Ticket ID sample formula" class="image img-screenshot" id="topic_l1j_fxn_dhb__image_sgs_gzn_dhb" src="https://zen-marketing-documentation.s3.amazonaws.com/docs/en/Explore_formula_4.png"></p>
<p class="p">The brackets indicate to Explore that this is a metric or attribute. An
alternative method to enter a metric or attribute is to simply begin typing. Explore
recognizes the brackets, and suggests the appropriate values to choose
from.</p>
<p class="p"><img alt="Explore field auto-suggest" class="image img-screenshot" id="topic_l1j_fxn_dhb__image_bqx_szn_dhb" src="https://zen-marketing-documentation.s3.amazonaws.com/docs/en/Explore_formula_5.png"></p>
</li>
</ol>
<p class="p">If you want to add an aggregator to your metric or attribute, enter the text in capitals
before the first bracket, for example <strong class="ph b">COUNT[Ticket ID]</strong>.</p>
</div>
</div>
<div aria-labelledby="ariaid-title5" class="topic nested1" id="topic_a5p_pcd_dx">
<h2 class="title topictitle2" id="ariaid-title5">Adding functions to your formula</h2>
<div class="body">
<p class="p">To add functions to your formula, click <strong class="ph b">Add</strong> under <strong class="ph b">Functions</strong> or type in a
function name. As with metrics and attributes, Explore suggests auto-complete results for
any functions you type in. </p>
<p class="p">When you click <strong class="ph b">Add</strong>, the <strong class="ph b">Functions</strong> window opens. This window is useful if you
are not sure which function is applicable to the calculated element you want to create. All
functions in the window contain a brief explanation of their purpose. For a list of all
functions and many examples, see <a class="xref" href="https://support.zendesk.com/hc/en-us/articles/4408834558746-Using-dates-in-functions" target="_blank">Explore functions reference</a>. </p>
<p class="p"><img class="image img-screenshot" id="topic_a5p_pcd_dx__image_ffq_mzx_dx" src="https://zen-marketing-documentation.s3.amazonaws.com/docs/en/navigating_calculation31.png" width="450"></p>
<p class="p">If you are looking for a specific function, you can search for functions or filter by
function type. </p>
<div class="p">
<strong class="ph b">To filter functions</strong><ol class="ol" id="topic_a5p_pcd_dx__ol_jmp_ryx_dx">
<li class="li">In the <strong class="ph b">Functions</strong> window, click <strong class="ph b">Filter</strong>. </li>
<li class="li">Type in a category or select a category from the drop-down list. <p class="p"><img alt="Explore function categories" class="image img-screenshot" id="topic_a5p_pcd_dx__image_u4h_v14_dhb" src="https://zen-marketing-documentation.s3.amazonaws.com/docs/en/Explore_formula_6.png"></p>
</li>
<li class="li">Click the <strong class="ph b">x</strong> next to the category name to remove the filter. </li>
</ol>
</div>
</div>
</div>
<div aria-labelledby="ariaid-title6" class="topic nested1" id="topic_jtq_zh4_vyb">
<h2 class="title topictitle2" id="ariaid-title6">Adding comments to your formula</h2>
<div class="body">
<p class="p">You can add comments to your formulas to explain how it works. This is helpful if you want
to collaborate on formulas with other users, or if you want to make notes for yourself on
why you built the formula the way you did.</p>
<p class="p"><strong class="ph b">To add a comment in a formula</strong></p>
<ol class="ol" id="topic_jtq_zh4_vyb__ol_bmb_k34_vyb">
<li class="li">Find the place in a formula where you want to insert a comment.</li>
<li class="li">Type a forward slash and an asterisk (/*), type your comment, and then type an asterisk
and a forward slash (*/).<p class="p"><img class="image" id="topic_jtq_zh4_vyb__image_jpw_z34_vyb" src="https://zen-marketing-documentation.s3.amazonaws.com/docs/en/explore_formula_with_comment.png" width="600"></p>
<div class="p">
<div class="note warning" id="topic_jtq_zh4_vyb__note_yjd_2j4_vyb">
<span class="warningtitle">Warning:</span> Clicking <strong class="ph b">Format</strong> removes all comments.
If you click <strong class="ph b">Format</strong> and want to restore your comments, click anywhere outside
the panel to close it without saving your changes.</div>
</div>
</li>
</ol>
</div>
</div>
<script id="docs-schema-markup" type="application/ld+json">{
"@context": "https://schema.org",
"@type": "TechArticle",
"@id": "https://support.zendesk.com/hc/en-us/articles/4408836190362",
"url": "https://support.zendesk.com/hc/en-us/articles/4408836190362",
"headline": "Writing Explore formulas",
"description": "You can create custom formulas using metrics, attributes, and functions to perform calculations and conditions on your data for tailored reporting in Explore.",
"articleSection": "Writing formulas",
"datePublished": "2021-10-16T04:07:10+00:00",
"dateModified": "2026-05-15T23:23:14.193519+00:00",
"inLanguage": "en",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://support.zendesk.com/hc/en-us/articles/4408836190362"
},
"author": {
"@type": "Organization",
"name": "Zendesk",
"@id": "https://www.zendesk.com"
},
"publisher": {
"@type": "Organization",
"name": "Zendesk",
"@id": "https://www.zendesk.com"
},
"isPartOf": {
"@type": "WebSite",
"name": "Zendesk Help",
"@id": "https://support.zendesk.com/hc/"
},
"about": {
"@type": "SoftwareApplication",
"name": "Zendesk",
"@id": "https://www.zendesk.com",
"softwareAddOn": {
"@type": "SoftwareApplication",
"name": "Explore",
"@id": "https://support.zendesk.com/hc/en-us/sections/4405298856346"
}
}
}</script>
</body>