# Calculated fields return null values

**URL:** <https://community.hubspot.com/t/calculated-fields-return-null-values/129401>\
**Category:** Data Hub\
**Tags:** format-data-actions\
**Created:** [April 7, 2025, 6:08pm UTC](https://community.hubspot.com/t/calculated-fields-return-null-values/129401 "2025-04-07T18:08:28Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Huntscape-Ops](https://avatars.discourse-cdn.com/v4/letter/h/848f3c/32.png) [@Huntscape-Ops](https://community.hubspot.com/u/Huntscape-Ops)\
**Post date:** [April 7, 2025, 6:08pm UTC](https://community.hubspot.com/t/calculated-fields-return-null-values/129401/1 "2025-04-07T18:08:28Z")

</div>

I am trying to use a calculated field, but if one of the values is empty in the calculation, then it returns a null value.

([properties.imported\_total] + [properties.total\_donations])

There has to be an easy way to fix this but chatgpt is telling me to use ops hub (which is fine) and use this formula in the format data step of the workflow: {{ properties.imported\_total | default(0) }} + {{ properties.total\_donations | default(0) }}

But that causes an error in the custom code step. Please help

---

<div class="post-metadata">

**Author:** ![karstenkoehler](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/karstenkoehler/32/68554_2.png) [@karstenkoehler](https://community.hubspot.com/u/karstenkoehler)\
**Post date:** [April 7, 2025, 6:11pm UTC](https://community.hubspot.com/t/calculated-fields-return-null-values/129401/2 "2025-04-07T18:11:38Z")

</div>

Hi @Huntscape-Ops,

You can solve this with an ‘if’ statement and the ‘is known’ function, both available through drop downs in the formula editor - no Operations Hub required. If the number is known, return the number, if not, return a 0. Repeat the same for the second part of the calculation and that should do the trick.

 ![karstenkoehler_0-1744049647724.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/6/5/65f969f6be203717b9678cc60bc611b88064defd.png)

Best regards

---

<div class="post-metadata">

**Author:** ![Huntscape-Ops](https://avatars.discourse-cdn.com/v4/letter/h/848f3c/32.png) [@Huntscape-Ops](https://community.hubspot.com/u/Huntscape-Ops)\
**Post date:** [April 7, 2025, 6:38pm UTC](https://community.hubspot.com/t/calculated-fields-return-null-values/129401/3 "2025-04-07T18:38:02Z")

</div>

Thank you for the quick reply but I am not advanced enough to do that. I  
keep getting errors in the calculation

---

<div class="post-metadata">

**Author:** ![karstenkoehler](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/karstenkoehler/32/68554_2.png) [@karstenkoehler](https://community.hubspot.com/u/karstenkoehler)\
**Post date:** [April 7, 2025, 6:46pm UTC](https://community.hubspot.com/t/calculated-fields-return-null-values/129401/4 "2025-04-07T18:46:04Z")

</div>

@Huntscape-Ops can you please share a screenshot? If you type the shown formula exactly, you shouldn’t get any errors.

---

<div class="post-metadata">

**Author:** ![Huntscape-Ops](https://avatars.discourse-cdn.com/v4/letter/h/848f3c/32.png) [@Huntscape-Ops](https://community.hubspot.com/u/Huntscape-Ops)\
**Post date:** [April 7, 2025, 6:49pm UTC](https://community.hubspot.com/t/calculated-fields-return-null-values/129401/5 "2025-04-07T18:49:42Z")

</div>

This is my original calculation but it puts out null value when one of the fields is empty.

 ![HuntscapeOps_0-1744051735037.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/5/5a37f6e9120340edb5e9f2db3bf82488ef5bedb3.png)

I have no idea how to adapt this to “if” and “is known” as you were describing.

Any help would be greatly appreciated

---

<div class="post-metadata">

**Author:** ![karstenkoehler](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/karstenkoehler/32/68554_2.png) [@karstenkoehler](https://community.hubspot.com/u/karstenkoehler)\
**Post date:** [April 7, 2025, 6:52pm UTC](https://community.hubspot.com/t/calculated-fields-return-null-values/129401/6 "2025-04-07T18:52:42Z")

</div>

@Huntscape-Ops there’s no special trick to this - just find the screenshot I shared in my earlier reply and type that exactly into the formula field, character by character 🙂

---

<div class="post-metadata">

**Author:** ![Huntscape-Ops](https://avatars.discourse-cdn.com/v4/letter/h/848f3c/32.png) [@Huntscape-Ops](https://community.hubspot.com/u/Huntscape-Ops)\
**Post date:** [April 7, 2025, 7:01pm UTC](https://community.hubspot.com/t/calculated-fields-return-null-values/129401/7 "2025-04-07T19:01:14Z")

</div>

I lied. The formula no longer has errors but I am still getting null values in the calculated field

---

<div class="post-metadata">

**Author:** ![karstenkoehler](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/karstenkoehler/32/68554_2.png) [@karstenkoehler](https://community.hubspot.com/u/karstenkoehler)\
**Post date:** [April 7, 2025, 7:02pm UTC](https://community.hubspot.com/t/calculated-fields-return-null-values/129401/8 "2025-04-07T19:02:51Z")

</div>

@Huntscape-Ops can you please share a screenshot and the error message? I can’t help if I don’t have any details.

---

<div class="post-metadata">

**Author:** ![Huntscape-Ops](https://avatars.discourse-cdn.com/v4/letter/h/848f3c/32.png) [@Huntscape-Ops](https://community.hubspot.com/u/Huntscape-Ops)\
**Post date:** [April 7, 2025, 7:04pm UTC](https://community.hubspot.com/t/calculated-fields-return-null-values/129401/9 "2025-04-07T19:04:37Z")

</div>

Does this help

 ![HuntscapeOps_0-1744052623041.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/3/1/3187ff49ca20e92f792eae06e6246df9a3a08cb7.png)

---

<div class="post-metadata">

**Author:** ![karstenkoehler](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/karstenkoehler/32/68554_2.png) [@karstenkoehler](https://community.hubspot.com/u/karstenkoehler)\
**Post date:** [April 7, 2025, 7:08pm UTC](https://community.hubspot.com/t/calculated-fields-return-null-values/129401/10 "2025-04-07T19:08:33Z")

</div>

@Huntscape-Ops strange - can you save this and see if it populates correctly on records? It should work, see my screenshot. If it doesn’t after refreshing, I’d recommend checking with HubSpot support.

---

<div class="post-metadata">

**Author:** ![Huntscape-Ops](https://avatars.discourse-cdn.com/v4/letter/h/848f3c/32.png) [@Huntscape-Ops](https://community.hubspot.com/u/Huntscape-Ops)\
**Post date:** [April 7, 2025, 7:10pm UTC](https://community.hubspot.com/t/calculated-fields-return-null-values/129401/11 "2025-04-07T19:10:50Z")

</div>

I refreshed the screen and put the formula back in, and it is working now.

Thank you so much

---

<div class="post-metadata">

**Author:** ![Huntscape-Ops](https://avatars.discourse-cdn.com/v4/letter/h/848f3c/32.png) [@Huntscape-Ops](https://community.hubspot.com/u/Huntscape-Ops)\
**Post date:** [April 7, 2025, 7:07pm UTC](https://community.hubspot.com/t/calculated-fields-return-null-values/129401/12 "2025-04-07T19:07:02Z")

</div>

Wow that worked. I had 1 space off.  
Thank you so much
