Using the IF THEN ELSE function

Return to top

10 Comments

  • Andrei Kamarouski
    Community Moderator
    The Wise One - 2021

    Graeme, Eugene,

    Hi guys, 

    It seems that using attributes values directly in formulas is not working for proper calculations (I just receive all tickets instead of intended tickets with the non-blank value in my custom field).

    You are writing about using attributes in the formula, but showing examples with tags of those attributes. Is this the proper way to build metrics for custom ticket fields? The documentation is not clear here or do I miss something? 

    0
  • Rob Stack
    Zendesk Documentation Team

    Hi Andrei Kamarouski, could you try removing the quotes from "NULL"? NULL isn't a value, it's essentially "nothing" :-) 
    There's a similar example of what you're trying to do in this article.

    I hope this helps, but do let us know if you need more help. Thanks!

    0
  • Andrei Kamarouski
    Community Moderator
    The Wise One - 2021

    Hi @..., I see now! =) Thx! 😊 

    1
  • Adam Wideman

    I'm not sure if I'm doing this totally correct or if I need to make a whole different set of custom metrics to pull this off, but I'm trying to add some custom fields to my Organizations for "Service Agreements".  Each agreement, of which there are 3 for each organization possible, would have a "Contract Number", "Hours Purchased", and a "Contract Value".  I need to pull in Hours Purchased and Contract Number in order to run a query against how many "hours billed" against the "Hours Purchased".  I've been able to do this easily with just one contract, but now its causing some erroneous data when we have multiple contracts involved.  SO  I want a field thats SUPER smart.  I need one that knows to show hours purchased relevant to which Contract Number is used.  The matching field is called "Ticket Sage Reference" (also custom) and lives in the ticket.  I want to say something like

    IF ([Ticket Sage Reference]=VALUE(ContractNumber))
    THEN 1
    ELSE IF ([Ticket Sage Reference]=VALUE(ContractNumber2))
    THEN 2
    ELSE IF ([Ticket Sage Reference]=VALUE(ContractNumber3))
    THEN 3
    ENDIF

    Then one that would ACTUALLY display the content

    IF ([CustomMetric]=1)
    THEN VALUE(ContractNumber1)
    ELSE IF ([CustomMetric]=2)
    THEN VALUE(ContractNumber2)
    ELSE IF ([CustomMetric]=3)
    THEN VALUE(ContractNumber3)
    ENDIF

    I'm terrible with functions, please send help . I think I may even be at the point where I may even pay Zendesk to write this for me, but wanted to see if anyone could steer me in the right direction before i did that.

    0
  • Rob Stack
    Zendesk Documentation Team

    Hi Adam Wideman, thanks for the question. I'm not sure if you can do exactly what you need here. However, I really think it would be worth you asking this in our Explore Q and A section at 

    https://support.zendesk.com/hc/en-us/community/topics/360001200893

    A lot more customers will see it there and it's always possible that someone has worked out a solution to this. Thanks!

    0
  • CaSonya Featherston

    I have a question, I am trying to build a query for unsolved tickets with ID as well as the number of days the ticket has been open.  Would this be a IF-THEN-ELSE calculation or is there an attribute that will give me these results?

    0
  • Elaine
    Zendesk Customer Care

    Hi CaSonya,

    Please check out the Explore recipe: Reporting on the duration of fields as that would provide you the time a ticket has been set to a specific status throughout its lifecycle. Hope this helps! :)

    0
  • Sigmund Domingo

    Product: Support

    Dataset: Updates History

    I have managed to create a calculated field that would display a value of "1" when the Breached SLA Status is "0" with the following formula:

    IF (D_COUNT(Breached SLA tickets)=0) THEN 1 ELSE 0 ENDIF

    Is there a way for us to get the sum of that value? I am trying to get the weighted average of this metric to get the calculated SLA% per Ticket Group. However, I could not get a SUM function to work. I could not use the same calculation using "SLA target status" as this is not a Metric.

    0
  • Gab Guinto
    Zendesk Customer Care
    Hi Sigmund,
     
    I played around with other Explore functions and I also wasn't able to build a similar metric that works with the SUM aggregator. A workaround that I can suggest is to build a custom Tickets metric under the SLA dataset –

    – and then another metric to subtract the count of breached SLA tickets from the total count of tickets.

    This should give you the count of tickets without any breached SLA. You'll be able to slice the results from this metric by ticket group or other attributes. 
    1
  • Sigmund Domingo

    Hi Gab,

    I was able to use the calculated metrics function you have mentioned to create a new Service Level metric.

     

    Thank you for your insights.

    0

Please sign in to leave a comment.

Powered by Zendesk