Calculated Field if value empty

I'm trying to create a calculated date field that will calculate differently based on if the target field is empty or not, so:

if the $build_commencement_date_c date field is empty, 

addDays(build_stage_revised_start_c,$build_stage_days_slab_)

if $build_commencement_date_c date field is not empty

addDays($build_commencement_date_c,$build_stage_days_slab_c)

After reviewing responses to previous posts, I have pieced together:

ifElse(equal($build_commencement_date_c,""),addDays(build_stage_revised_start_c,$build_stage_days_slab_c),

ifElse(greaterThan($build_commencement_date_c,0),addDays($build_commencement_date_c,$build_stage_days_slab_c),0))

but it's not working, and is possibly completely off track!

Can anyone help??

Parents
  • Hi , if the field is not empty, we should be careful in using addDays on top of the same field, since it might keep incrementing the number after every save.

    Here is a simple formula which sets your build_commencement_date based on whether it's empty or not. If it's empty, it will addDays to build_stage_revised_start, if not, will just leave the value as-is:

    ifElse(equal($build_commencement_date_c,""),addDays($build_stage_revised_start_c,$build_stage_days_slab_c),$build_commencement_date_c)

    To explain this a little better:

    ifElse(
    equal($build_commencement_date_c,""), -- Criteria
    addDays($build_stage_revised_start_c,$build_stage_days_slab_c), -- Date is empty
    $build_commencement_date_c -- Date is not empty, don't alter it
    )

    Date value cannot be "zero", so you cannot set that as a value.

  • Hi ,

    Thanks for the reply.  Your suggested formula returns only one calculated value, however I needed a further calculation when date is not empty.

    Sugar support provided the following formula, which works perfectly.

    ifElse(equal($sent_to_site_c,""),
    addDays($build_stage_revised_sent_c,$build_stage_days_start_c),
    addDays($sent_to_site_c,$build_stage_days_start_c))

    However your explanation assisted with another formula with was causing me grief - so thanks :-)

Reply
  • Hi ,

    Thanks for the reply.  Your suggested formula returns only one calculated value, however I needed a further calculation when date is not empty.

    Sugar support provided the following formula, which works perfectly.

    ifElse(equal($sent_to_site_c,""),
    addDays($build_stage_revised_sent_c,$build_stage_days_start_c),
    addDays($sent_to_site_c,$build_stage_days_start_c))

    However your explanation assisted with another formula with was causing me grief - so thanks :-)

Children
No Data