Using the IF THEN ELSE function

Have more questions? Submit a request


  • Ayal Kellman



    I'm trying to use an IF statement to set static KPI targets by priority but I am getting no data. 

    Here is the statement I was trying to use: 

    IF ([Ticket priority] = "Urgent") THEN
    ELIF ([Ticket priority] = "High") THEN
    ELIF ([Ticket priority] = "Normal") THEN

    In other words, I want to show last week's first reply times in a table as they compare to our target first reply times. 

    Can anyone help or share some insight?

    Thanks :)

  • Kyle Jones

    Hey there Ayal,


    This might require a bit more digging into to properly assess the report you're trying to build, as there are a few questions I need to ask you. I'm going to pull this into a ticket so we can continue the discussion!


    Thank you for your patience,

  • Fiona

    Hi there

    I'm trying to calculate NPS score using a custom numeric field I made in Support. I enter the number between 0-10 manually in a custom user field. If I assign 9 or 10, they should be considered a 'promoter', 7-8 should be a 'neutral' and the rest should be 'detractor'. I then want to perform the following calculation in Explore:

    Promoter % – Detractor % = NPS

    I guess I need to make this using an IF statement, followed by a custom metric, but I'm not sure how. Here's where I'm at so far. Any help is appreciated!


  • Rob Stack
    Hi Fiona, this set me thinking, and I believe I have a way you can do this. I didn’t have any test figures to try this with, but did confirm that the formulas are sound. Consider it a starting point!  If anyone knows a better method to do this, I’m sure they will jump in.
    You’ll actually need to create four custom metrics. Do let me know how this works out for you!
    1. Total scored tickets (Total tickets with a score]. (Use COUNT aggregator)
                IF NOT ([NPS Score] = NULL) THEN [Ticket ID] ENDIF      = Total number of tickets with a score
    1. Promoter.  (Use COUNT aggregator)
                IF ([NPS Score]>8) THEN [Ticket ID] ENDIF
    1. Detractor.  (Use COUNT aggregator)
                IF ([NPS Score]<7 THEN [Ticket ID] ENDIF
    1. NPS score.  (I think this should be the SUM aggregator, but you’ll need to test)
                (([Promoter]/[Total scored tickets])*100) - (([Detractor]/[Total scored tickets])*100)
  • Fiona

    Amazing, thanks Rob! 

    Forgive my beginner questions, but does this still work if the custom field 'NPS Score' is on the user and not on a ticket? 

    Also, when I tried to make it, NPS Score wasn't an option in the first formula (I haven't got beyond the first one yet). I did get offered NPS comments instead by autocomplete, which is a text box custom user field I added.


  • Rob Stack

    Glad it helped and it's really not a beginners question!

    I did a quick experiment and you might be able to use [Requester ID] instead of [Ticket ID]. You would need to set the aggregator to DCOUNT (which will only count each requester once).

    That would look at all users who requested tickets, but only those with an associated NPS score. See if that works for you!

  • Fiona

    Thanks Rob! That makes sense. 

    I'm not being offered NPS Score in the formula maker - only NPS comments and NPS category (two non-numeric custom user fields I made) so I'm not sure what is happening. It lets me make the custom metric but doesn't recognise [NPS Score] then presents an error when I add the metric to my new query



  • Rob Stack

    Can you see if it's available if you use a custom attribute?

    From this article, it depends on how the field is configured. You mentioned that you enter it manually. If you type it in, it might have been created as an attribute. See: 

    If you can't find it, we'll open a ticket so someone can dig into this a bit further with you :-)

  • Fiona

    Thanks, Rob. The screenshot above is when I click on metrics, so it's showing there as a numeric custom field, but doesn't show when I start typing NPS in the formula sentence. The other two custom fields I mentioned are showing when I select to add an attribute, so they all seem properly sorted at that level. 

    Thanks for your help!

  • Rob Stack

    Thanks Fiona! That clearly seems like it shouldn't be happening. I've opened a ticket for you as I'd love us to help you get to the bottom of this!

  • Fiona

    Amazing, thank you!


Please sign in to leave a comment.

Powered by Zendesk