is there any way where we can use 1 instead of 0 i...
# suitescript
p
is there any way where we can use 1 instead of 0 in CASE WHEN's ELSE. using 1 in ELSE gives Error:Invalid Expression
j
Not sure I'm following... you can use either. Can use 99999999 if you want. Care to share your SQL expression?
p
((CASE WHEN TO_CHAR({transaction.trandate},'YYYY')=TO_CHAR({today},'YYYY')AND{transaction.trandate}<={today}THEN{transaction.amount}ELSE 0 END-CASE WHEN TO_CHAR({transaction.trandate},'YYYY')=TO_CHAR({today},'YYYY')-1 THEN{transaction.amount}ELSE 0 END)*100)/ NULLIF(CASE WHEN TO_CHAR({transaction.trandate},'YYYY')=TO_CHAR({today},'YYYY')-1 THEN{transaction.amount}ELSE 0 END,0)
this formula is to calculate the growth rate
this is returning wrong value
(CASE WHEN TO_CHAR({transaction.trandate},'YYYY')=TO_CHAR({today},'YYYY')AND{transaction.trandate}<={today}THEN{transaction.amount}ELSE 0 END-CASE WHEN TO_CHAR({transaction.trandate},'YYYY')=TO_CHAR({today},'YYYY')-1 THEN{transaction.amount}ELSE 0 END)/CASE WHEN TO_CHAR({transaction.trandate},'YYYY')=TO_CHAR({today},'YYYY')-1 THEN{transaction.amount}ELSE 0 END)*100
this formula gives possible division by zero
j
You'll either want to do a NULLIF 0 in the part under the divide by.
Copy code
(CASE WHEN TO_CHAR({transaction.trandate},'YYYY')=TO_CHAR({today},'YYYY')AND{transaction.trandate}<={today}THEN{transaction.amount}ELSE 0 END-CASE WHEN TO_CHAR({transaction.trandate},'YYYY')=TO_CHAR({today},'YYYY')-1 THEN{transaction.amount}ELSE 0 END)/NULLIF(CASE WHEN TO_CHAR({transaction.trandate},'YYYY')=TO_CHAR({today},'YYYY')-1 THEN{transaction.amount}ELSE 0 END, 0))*100
p
Thats giving error , invalid expression