Forum Discussion

aaronb's avatar
aaronb
New Contributor
7 years ago

Nested ternary expression using Match operator

Expression:
parseFloat($InvoiceTotal1.trim()) < 0 && $CategoryDescription.trim() == “INVOICE ADJUSTMENTS” ? parseFloat($InvoiceAdjustments.trim()) : (parseFloat($InvoiceTotal1.trim()) > 0 && $CategoryDescription.trim() == “INVOICE ADJUSTMENTS” ? parseFloat($InvoiceAdjustments.trim()) : (parseFloat($InvoiceTotal1.trim()) < 0 ? parseFloat($CategorySalesValue.trim())+parseFloat($CategoryDiscountAllowance.trim()) : parseFloat($CategorySalesValue.trim())+parseFloat($CategorySalesTax.trim())))

Description:
Hi,
I am using the above ternary expression to handle essntially four different conditions. I used a ternary expression for timing purposes but long term I think it would make sense to use the match operator or something similar. I explored this option but never could get the syntax correct. If anyone has some experience with something similar that they could help point me in the right direction I would greatly appreciate it!

Thank you

Sample:
See above

Release used:
4.16