# Custom Property Calculation with a Condition

**URL:** <https://community.hubspot.com/t/custom-property-calculation-with-a-condition/105985>\
**Category:** Tips, Tricks & Best Practices\
**Tags:** enterprise\
**Created:** [April 29, 2024, 10:12am UTC](https://community.hubspot.com/t/custom-property-calculation-with-a-condition/105985 "2024-04-29T10:12:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BGreen92](https://avatars.discourse-cdn.com/v4/letter/b/aeb1de/32.png) [@BGreen92](https://community.hubspot.com/u/BGreen92)\
**Post date:** [April 29, 2024, 10:12am UTC](https://community.hubspot.com/t/custom-property-calculation-with-a-condition/105985/1 "2024-04-29T10:12:42Z")

</div>

Hello,

I have been implementing a property onto deals that calculate the number of days the deal has been in a deal stage.

I’m using a custom formula on a property:

`time_between([properties.date_became_sales_qualified_lead_in_pipeline],[properties.todays_date])`

I need to add a condition to this to stop the property from updating when it exits the Sales Qualified Lead Stage. At the moment, it continues to count.

Thank you

---

<div class="post-metadata">

**Author:** ![colinwitt](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/colinwitt/32/67676_2.png) [@colinwitt](https://community.hubspot.com/u/colinwitt)\
**Post date:** [April 29, 2024, 2:47pm UTC](https://community.hubspot.com/t/custom-property-calculation-with-a-condition/105985/2 "2024-04-29T14:47:51Z")

</div>

Hey @BGreen92,  
maybe you could try to add an if-condition to your formula. Something like this:

`if([properties.lifecyclestage]="salesqualifiedlead")`

But I’m not sure if that fully works as the calculated properties always continue to calculate. Another option might be to extract the calculated value into another static property at a time where it’s correct (with a “copy property value” workflow action).  
Best regards  
Colin

---

<div class="post-metadata">

**Author:** ![BGreen92](https://avatars.discourse-cdn.com/v4/letter/b/aeb1de/32.png) [@BGreen92](https://community.hubspot.com/u/BGreen92)\
**Post date:** [April 29, 2024, 3:28pm UTC](https://community.hubspot.com/t/custom-property-calculation-with-a-condition/105985/3 "2024-04-29T15:28:43Z")

</div>

Thank you, Colin; I have managed to get this to work. I’ll post the solution for others just in case they need to achieve a similar scenario.

Here’s the code that I have used to auto-update a property on a deal, telling me how many days the deal sat in that stage.

_if(([properties.dealstage] == “1234567”), time\_between([properties.date\_became\_pql],[properties.todays\_date]), if((((([properties.dealstage] == “1234568”) || ([properties.dealstage] == “12345689”)) || ([properties.dealstage] == “12345690”)) || ([properties.dealstage] == “12345691”)),time\_between([properties.date\_became\_pql],[properties.hs\_date\_deal\_exited\_stage])))_
