Ignoring negative values while adding or subtracting values

Hi everyone,
I am building an XLSform which requires adding costs and revenues from various sources. The fields are filled in through survey responses.
I have the following directions in the survey:
“Enter the amount in Dollars.
Mark -96 if none
Mark -97 if not applicable
Mark -99 if something but don’t know”

How can I ignore these negative values while calculating total cost and total revenue?

Welcome to the community, @yashukalera! Will you be replacing them with 0 instead?

Thanks @Kal_Lam!
I would like to treat them as 0 solely for the purposes of totaling the costs and revenue, but would not like to change the survey responses.
For instance, if the survey responses are:
cost on x = $100
cost on y = -97 (because not applicable)
cost on z = $100
I want total cost to sum to $200 and ignore the -97 value. This could be treated as a 0 while summing up, but the response should remain as -97.

Hope this makes sense!

1 Like

HI @yashukalera, you could use a calculate question paired with the response value and use that result for your summation:


type name label calculation
decimal x Enter value
calculate x_calc if(${x} > 0, ${x}, 0)
decimal y Enter another value
calculate y_calc if(${y} > 0, ${y}, 0)
calculate total x_calc + y_calc

Hi @Josh, thank you for your solution, it worked perfectly.