# Looking to divide a field value in NS by 2

I’m trying to divide the value of a field based on whether a different checkbox field is checked or not checked.  I’ve tried many variables, not successfully divide.

CASE WHEN {Checkbox } = ‘YES’ THEN ({Field 1} / 2 ELSE {Field 1}) END

CASE WHEN {Checkbox } = ‘YES’ THEN ({Field 1}) / 2 ELSE ({Field 1}) END

The second formula returns the same value from Field 1 successfully without dividing, which is what I need most.

Rookie Asked on July 21, 2022 in

Has nothing to do with your parentheses (in fact, they’re not needed at all). Checkboxes return a ‘T’/’F’ or ‘1’/’0′ values depending on how you’re calling it within Netsuite.  IIRC saved searches is T/F and some scripting scenarios are 1/0. Yes, I know that the field outputs as ‘Yes’/’No’ when you add it to your search as a column, but that’s just NetSuite’s special way of messing with you. What it really is is T/F and that’s how you have to reference it in formulas.

So for your scenario, it would be:

CASE WHEN {Checkbox } = ‘T’ THEN {Field 1}/2 ELSE {Field 1} END

Do that. Should work like a charm. Then you can mark my answer the best for those sweet sweet internet points 😉

Intermediate Answered on July 21, 2022.

Thanks James, you are absolutely correct.  All good now!

on July 21, 2022.