Can't get rid of silly error

I have a calculation the canvas that performs a simple date subtraction. It has a formula that should prevent the operation from running when the date to be subtracted is not set. Nevertheless, instead of printing a blank space when this happens, it shows an error.

Hi, we can’t see your doc because it isn’t published publicly. Can you share it or post a screenshot of the error?

My mistake. It should be visible now.

Hi @Giovanni_Sades,

please use this Guide to share your doc with us:

Best regards
Jannis

2 Likes

Thanks, I hope it’s usable now.

1 Like

Hi @Giovanni_Sades,

The error is occurring because your formula is set to output a “duration”, but your If formula is outputting a text value (ie. “ “).

If you make that a “0” (zero) instead, it gives a fairly decent result - not entirely blank, but just a hyphen -

2 Likes

Thanks, Robin! That was driving me crazy. By the way, do you know if there’s a better way to handle the ELSE clause? Using "" returns [], which doesn’t look great.

1 Like

You’re welcome.

I don’t have a better solution for the ELSE clause - what you’ve done is what I do. That’s not to say there isn’t one … perhaps someone else can chime in? I’d love to know it too! :grimacing:

1 Like

@Giovanni_Sades Have you tried using a SwitchIf instead of an If? Using a SwitchIf will allow you to only apply values to items meeting the mentioned condition and will return nothing for items without that condition

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.