I hear you guys might be able to help me with an S...
# suiteanalytics
k
I hear you guys might be able to help me with an SQL/formula issue 🙂 I can't tell what's going wrong with this formula, but Netsuite sure thinks something's wrong:
Copy code
NVL2(
  { item.averagecost },
  TRUNC(
    SUM(
      NVL({ amount }, 0) - NVL({ item.averagecost }, 0) * { quantity }
    ) / SUM(NULLIF({ amount }, 0)),
    2
  ) * 100,
  TRUNC(
    SUM(
      NVL({ amount }, 0) - NVL({ item.lastpurchaseprice }, 0) * { quantity }
    ) / SUM(NULLIF({ amount }, 0)),
    2
  ) * 100
)
I've verified that both of the
TRUNC()
blocks work outside of the
NVL2
, but Netsuite throws an error when trying to save the above. Anyone have an idea why?