If statement in a report

If there any way to do some conditional statements in a report? I would like to highlight if one of my customers is from the United States (because we charge them using a non-local USD credit card machine).

I have tried:

[Sales Tickets:.8,3,1,1,1,1,1,1,1,1,1,1]
>#|Name|Total
@{REPORT TICKET DETAILS:T.Id:(TY=Sales Ticket)::,}
{REPORT TICKET DETAILS:T.TicketNumber,EC.Full Name,EC.Country,T.TotalAmount:T.Id=$1:{0}|{1} [='{2}' == 'United States' ? '(USA) : '']|{3}}

AND

[Sales Tickets:.8,3,1,1,1,1,1,1,1,1,1,1]
>#|Name|Total
@{REPORT TICKET DETAILS:T.Id:(TY=Sales Ticket)::,}
{REPORT TICKET DETAILS:T.TicketNumber,EC.Full Name,EC.Country,T.TotalAmount:T.Id=$1:{0}|{1} {CALL:tkt.isUSA('{2}')|{3}}

In the second example I am trying to offload the if statement to a separate script, but the problem is that it seems that {2} is what is passed to the script (rather than the name of the country itself).

Any way I could achieve this?

Your missing the closing quote on the (USA) on that one if ternary expressions do work that one is not right anyway…

Whoops - That was a copy/paste error, but even with that quote it doesn’t work. It seems like the : in the IF statement is treated like colons normally are in REPORT tags and therefore it seems to break everything.

Possibly,
Can you not have the report line twice and constrain the whole expression with normal report constraints?
Something like;

{REPORT TICKET DETAILS:T.TicketNumber,EC.Full Name,EC.Country,T.TotalAmount:T.Id=$1 and ,EC.Country=United States:{0}|{1}|’(USA)’|{3}}
{REPORT TICKET DETAILS:T.TicketNumber,EC.Full Name,EC.Country,T.TotalAmount:T.Id=$1 and ,EC.Country!=United States:{0}|{1}||{3}}

2 Likes

Ahhh, yes, good plan :slight_smile:

Cheers @JTRTech