Skip to main content
Solved

IIF statement returning a syntax error

  • August 21, 2025
  • 7 replies
  • 119 views
  • Translate All

I am trying to make credit memo numbers return a negative amount and leave the all other doc types positive. This is the code I wrote and I cannot figure out how to get this to work correctly. Any help is appreciated.

 

=IIf([ARInvoice.DocType]='Credit Memo',(IIf([ARTaxTran.CuryTaxableAmt]<>Null Or [ARTaxTran.CuryTaxableAmt]<>0,-([ARInvoice.CuryDetailExtPriceTotal]-[ARTaxTran.CuryTaxableAmt]),0))),(IIf([ARTaxTran.CuryTaxableAmt]<>Null Or [ARTaxTran.CuryTaxableAmt]<>0,([ARInvoice.CuryDetailExtPriceTotal]-[ARTaxTran.CuryTaxableAmt]),0))

 

Best answer by DrewNisley

​@jlindsey It is because of the DocType part of your IIf statement. It should actually be ‘CRM’ not ‘Credit Memo’. That is how it is saved in the database. Here’s the list of how they’re saved.

 

View original

7 replies

darylbowman
Captain II
Forum|alt.badge.img+17

Try this:

IIf(IsNull([ARTaxTran.CuryTaxableAmt],0)<>0,([ARInvoice.CuryDetailExtPriceTotal]-[ARTaxTran.CuryTaxableAmt])*IIf([ARInvoice.DocType]='Credit Memo',-1,1),0)

 

Translate

  • Author
  • Freshman I
  • August 21, 2025

Try this:

IIf(IsNull([ARTaxTran.CuryTaxableAmt],0)<>0,([ARInvoice.CuryDetailExtPriceTotal]-[ARTaxTran.CuryTaxableAmt])*IIf([ARInvoice.DocType]='Credit Memo',-1,1),0)

 

This throws up a lot of errors. I’m not at my desk right now but I can add a picture of all the errors popping up. 

Translate

  • Author
  • Freshman I
  • August 21, 2025

So I figured out that I was missing some parentheses in one area and had too many in another. BUT the value will not show up as negative no matter how I format it. I have tried *-1, (-1), -, -(formula)…

=IIf([ARInvoice.DocType]='Credit Memo',(IIf([ARTaxTran.CuryTaxableAmt]<>Null Or [ARTaxTran.CuryTaxableAmt]<>0,-([ARInvoice.CuryDetailExtPriceTotal]-[ARTaxTran.CuryTaxableAmt]),0)),(IIf([ARTaxTran.CuryTaxableAmt]<>Null Or [ARTaxTran.CuryTaxableAmt]<>0,([ARInvoice.CuryDetailExtPriceTotal]-[ARTaxTran.CuryTaxableAmt]),0)))

Translate

DrewNisley
Pro I
Forum|alt.badge.img+4

​@jlindsey It is because of the DocType part of your IIf statement. It should actually be ‘CRM’ not ‘Credit Memo’. That is how it is saved in the database. Here’s the list of how they’re saved.

 

Translate

darylbowman
Captain II
Forum|alt.badge.img+17

​...It should actually be ‘CRM’ not ‘Credit Memo’

Oh boy. How did I miss that.

Translate

DrewNisley
Pro I
Forum|alt.badge.img+4

Oh boy. How did I miss that.

Hehe, happens to the best of us 😄

Translate

JSpikowski
Jr Varsity II
Forum|alt.badge.img
  • Jr Varsity II
  • August 22, 2025

Typos and assumptions are are programmers greatest foe.

 

Translate