Help with custom equation property

What I currently have:

(([properties.invoice_sent_date] - [properties.todays_date]) - ([properties.customer_io_global_suppression_date] - [properties.customer_io_suppression_removal_date]))

This works, however if If “customer_io_suppression_removal_date” and “customer_io_global_suppression_date” are unknown, I would like to calculate just (invoice_sent_date - todays_date)

Hey, @RDePauw3 :waving_hand: Welcome to our community! Thanks for the interesting question. I’d like to invite some of our community experts who have experience with calculation properties to the conversation — @Josh @louischausse @HFisher7 have you built anything similar recently?

Thank you very much! — Jaycee

Calcuation fields allows the is_known and if functions. So you can run an if statement to check if those two fields are known and then output what you want for true and false conditions.

if ( is_known([properties.customer_io_suppression_removal_date]) && is_known([properties.customer_io_global_suppression_date]), 
(([properties.invoice_sent_date] - [properties.todays_date]) - ([properties.customer_io_global_suppression_date] - [properties.customer_io_suppression_removal_date])), 
([properties.invoice_sent_date] - [properties.todays_date]))

Breaking down the formula above should be (trying to make it easier to read):

IF

is_known([properties.customer_io_suppression_removal_date]) && is_known([properties.customer_io_global_suppression_date])

TRUE:

(

([properties.invoice_sent_date] - [properties.todays_date]) - ([properties.customer_io_global_suppression_date] - [properties.customer_io_suppression_removal_date])

)

FALSE:
([properties.invoice_sent_date ] - [properties.todays_date]))

After some tinkering I finally got this to work:

if((is_known([properties.customer_io_global_suppression_date]) && is_known([properties.customer_io_suppression_removal_date])), (time_between([properties.invoice_sent_date], [properties.todays_date]) - time_between([properties.customer_io_global_suppression_date], [properties.customer_io_suppression_removal_date])), time_between([properties.invoice_sent_date], [properties.todays_date]))