prevent negative values in calculations

By: Thomas Kutscher | Asked: 02/21/2024
ForumsCategory: How-toprevent negative values in calculations
Thomas Kutscher asked 3 months ago

We have some field calculations concerning reimbursements for employees.

Depending on their input the reimbursement can be reduced. But it doesn't have to be negative. How can i prevent this?

The final value is displayed in a number field, where all the math happens. When the value is negative, there should be 0

 

Thanks a lot, tom

1 Answers
Rob LeVineRob LeVine answered 3 months ago
Some of what you said seems contradictory, but I'll take a shot at answering. Try using the ternary operator as laid out on the Conditional Calculation page. Where you have something like [123]-[456] replace it with ([123]-[456]) < 0 ? 0 : [123]-[456]
Thomas Kutscher replied 3 months ago

Thanks for the advice - that helped me out 🙂 I haven't found that until now. And sorry for my confusing description... 😉

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right