Trouble with showing date with a condition

Hello community, I’m trying to write a formula that gives the timestamp “Time In Queue” if it meets the below conditions and I’m getting an error. Can you please provide help on this? I basically want it to bring over a time if the initiation method = inbound and those disconnect reasons, otherwise leave the Time in Queue as null or blank

sum(ifelse({Initiation Method}=‘INBOUND’ AND in({Disconnect Reason},[“AGENT_DISCONNECT”, “CUSTOMER_DISCONNECT”]),{Time In Queue},0))

Thanks
Patrick

Hi Pforbes, it looks like you’re on the right track with using the ifelse function to conditionally calculate values based on your specified criteria. However, your current formula is using sum outside the ifelse, which might not be appropriate unless you’re specifically looking to sum up all the times based on your conditions across your dataset. If you want to retain individual values for each record based on the conditions, you should place the aggregation (if needed) inside the ifelse` or adjust the formula to work without unnecessary summation.

Here’s a revised approach based on your requirements:

1. If you want to retain the time as is and only set it to zero when the conditions are not met: This formula will keep {Time In Queue} for rows that meet the condition or set it to null otherwise (or 0 if you prefer):

ifelse(
    {Initiation Method}='INBOUND' AND 
    in({Disconnect Reason}, ['AGENT_DISCONNECT', 'CUSTOMER_DISCONNECT']),
    {Time In Queue},
    null  // or use 0 if you specifically need zeros instead of null
)

2. If you are indeed trying to sum all the Time In Queue values based on the condition across your dataset :
You can embed the conditional logic within the aggregation function like so:

sum or sumOver (
    ifelse(
        {Initiation Method}='INBOUND' AND 
        in({Disconnect Reason}, ['AGENT_DISCONNECT', 'CUSTOMER_DISCONNECT']),
        {Time In Queue},
        0
    )
)

This version of the formula will sum all the times where the initiation method is ‘INBOUND’ and the disconnect reason is either ‘AGENT_DISCONNECT’ or ‘CUSTOMER_DISCONNECT’. It will add 0 for all other cases, thus not affecting the sum.

If you continue to receive errors, please check the data types of your fields to ensure they are compatible with the functions used (e.g., ensuring {Time In Queue} is a numerical type if you’re summing it), and double-check that all field names and syntax are correctly used.

Did this solution work for you? I am marking this reply as, “Solution,” but let us know if this is not resolved. Thanks for posting your questions on the Quick Sight Community!

This is excellent! it worked perfectly! Thanks so much