The Case statement handles multiple conditions (as opposed to If).
you can probably formulate this other ways, but this looks like what you describe:
not isempty(dateReferall) and not isempty(dateFinal), dateFinal - dateReferral;
not isempty(dateReferall) and not isempty(dateInterim); dateInterim - dateReferral;
getasnumber("") // or just 0
One of the benefits of doing calculations within the Let ( ) function is that you can avoid multiple calls on the same field. In David's Case calc you make up to 4 calls on one field and 2 each on the others. Using Let() enables you to make just one call on each by setting up each field as an internal variable:
dRef = dateReferal ;
dFin = dateFinal ;
dInt = dateInterim ;
result = Case(
not is empty ( dRef ) and not is empty ( dFin ) , dFin - dRef ;
not is empty ( dRef ) and not is empty ( dInt ) ; dInt - dRef ;
getasnumber ( "" ) // or just 0
I'm a big fan of Let (except in BASIC).
BASIC … bloody hell! That's going back a bit.