I am trying to run an if statement in the calculation box of my xlsForm, it currently looks like this:
if(${case_number}>=0,${case_number}, pulldata("@javascript","myFunctions.js","getMax","bid",pulldata("@property","token")))
The second part of the calculation calls a function that finds the maximum value of previous results, and adds one, creating the next, new case number.
The second part of the calculation, starting from pulldata, has worked as I would expect it too, however when I look at the dashboard that is bringing in the survey, the values are overwritten to show the next highest case number.
I wrote the if statement in the same row in the XLSForm as the function as shown below.

I want the calculation to determine whether the field already has a value or not, if it does, I want to keep it, and if it does not, I would like to run the pulldata calculation.
The odd thing was that this exact calculation worked when I moved it to a different field.
The error it is giving me says,:
b'ODKValidate Errors:\n>>Something broke the parser. See above for a hint.\nDependencycycles amongst the xpath expressions in relevant/calculate\n\nResult: Invalid'