Reporting - IF Function

SOLVED

I am trying to create an If function to show "ON HOLD" depending on the aged balance being over the credit limit for customers, but it keeps returning the following error - expecting "then", found "

What I have so far is IF SUM(Aged_Period_1+Aged_Period_2+Aged_Period_3+Aged_Period_Older)>SALES_LEDGER.CREDIT_LIMIT ? "ON HOLD" : " "

I did think it was something to do with the " but it returns the same error when I removed those parts and replaced with data fields.

  • 0
    SUGGESTED

    Hi SEDCOM,

    Thanks for using Community Hub,

    Presuming you're looking at this in the Sage Report Designer rather than Excel, the following guides will be helpful: If Statements > and Variables >

    Here are a couple of examples of the if statement you need sales ledger balance > credit limit ? "on hold":"" or AUDIT_HEADER.AGED_CUM_30 > Sales_ledger.credi_ limit ? " On Hold" :"" 

    You can also set up alerts if you want accounts not to get new orders: Custom alerts >

    If you're still encountering problems, I'd suggest logging a case online > 

    Regards,

    Andy
    Sage UKI

  • +1
    verified answer

    I think you are confusing the tertiary '"?:" operator (which has a value dependant on the <condition>):

    <condition> ? <true_value> : <false_value>

    with a normal conditional "IF-THEN-ELSE":

    IF <condition> THEN <true_statement> [ELSE <false_statement>]

    and trying to use both at the same time:

    IF SUM(Aged_Period_1...CREDIT_LIMIT ? "ON HOLD" : " "

    The IF is expecting a THEN keyword, and in parsing your statement it [probably] sees the bit SUM(...: " " as the condition for the IF and then fails to find the THEN it was looking for when it reaches the end of the line, on the final " (double quote).

    Try removing the IF keyword, ie:

    SUM(Aged_Period_1...CREDIT_LIMIT ? "ON HOLD" " "

    which will (should) make the expression have either the value "ON HOLD" or " " depending upon the condition of the sum being greater than the credit limit.

  • 0 in reply to Robert N

    Thank you so much Robert - that has fixed it!