# Creating a Function Using an If/Then Statement and Multiple Properties

**URL:** <https://community.hubspot.com/t/creating-a-function-using-an-if-then-statement-and-multiple-properties/112685>\
**Category:** CRM\
**Tags:** analytics-tools\
**Created:** [July 23, 2024, 10:03pm UTC](https://community.hubspot.com/t/creating-a-function-using-an-if-then-statement-and-multiple-properties/112685 "2024-07-23T22:03:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![KJoy3](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@KJoy3](https://community.hubspot.com/u/KJoy3)\
**Post date:** [July 23, 2024, 10:03pm UTC](https://community.hubspot.com/t/creating-a-function-using-an-if-then-statement-and-multiple-properties/112685/1 "2024-07-23T22:03:56Z")

</div>

Hi All!

I am look to create a custom function on a date property that mimics a formula I have used in Excel. The Excel formula is IF(cell1=“Annual”,(cell2+365),(cell2+90)). Essentially, I have a “Frequency” property whose dropdown includes “Annual”, “Quarterly”, etc. I want to create a function on a date property that reads IF “Frequency” = Annual then “Next Update Date” = Last Investor Update + 365. The function would also have to include an if/then for Quarterly frequency, etc. Is there a way to create this on a single property? Any other methods of approaching this would be greatly appreciated. Thank you!

---

<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:** [July 24, 2024, 4:07am UTC](https://community.hubspot.com/t/creating-a-function-using-an-if-then-statement-and-multiple-properties/112685/2 "2024-07-24T04:07:36Z")

</div>

Hi @KJoy3,

Yes, you should be able to do this with a calculation property: [Create calculation and rollup properties](https://knowledge.hubspot.com/properties/create-calculation-properties) (This requires a Professional or Enterprise subscription.)

The syntax is Excel-like and you get if functions and common operators to build your formula: [Create calculation and rollup properties](https://knowledge.hubspot.com/properties/create-calculation-properties#functions)

Keep in mind that HubSpot expects added durations in milliseconds, not days, e.g. 365 days would be 31536000000.

Without a Professional subscription this is not possible.

Let me know if you have any follow-up questions!

---

<div class="post-metadata">

**Author:** ![KJoy3](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@KJoy3](https://community.hubspot.com/u/KJoy3)\
**Post date:** [July 24, 2024, 4:22pm UTC](https://community.hubspot.com/t/creating-a-function-using-an-if-then-statement-and-multiple-properties/112685/3 "2024-07-24T16:22:45Z")

</div>

Thank Karsten! I managed to get the formula working for each frquency selection individually but I am unsure how to link them together into one long formula. Here are the formulas seperately. Any advice on what operators to use to combine them into one formula? Much appreciated!

if([properties.distribution\_frequency]= “Annual”,[properties.last\_investor\_update]+31536000000)

if([properties.distribution\_frequency]= “Quarterly”, [properties.last\_investor\_update]+7776000000)

if([properties.distribution\_frequency]= “Bi-Annual”, [properties.last\_investor\_update]+15,552,000,000)

---

<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:** [July 24, 2024, 4:41pm UTC](https://community.hubspot.com/t/creating-a-function-using-an-if-then-statement-and-multiple-properties/112685/4 "2024-07-24T16:41:22Z")

</div>

@KJoy3 nice 🙂 you should be able to simply join these with a + sign.

if([properties.distribution\_frequency]= “Annual”, properties.last\_investor\_update]+31536000000)+if([properties.distribution\_frequency]= “Quarterly”, [properties.last\_investor\_update]+7776000000)+if([properties.distribution\_frequency]= “Bi-Annual”, [properties.last\_investor\_update]+15,552,000,000)

Give it a try and let me know if that works.

---

<div class="post-metadata">

**Author:** ![KJoy3](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@KJoy3](https://community.hubspot.com/u/KJoy3)\
**Post date:** [July 24, 2024, 5:15pm UTC](https://community.hubspot.com/t/creating-a-function-using-an-if-then-statement-and-multiple-properties/112685/5 "2024-07-24T17:15:33Z")

</div>

Hi Karsten! While the formula doesn’t show any errors, testing doesn’t yield any dates. Any suggestions?

---

<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:** [July 24, 2024, 5:38pm UTC](https://community.hubspot.com/t/creating-a-function-using-an-if-then-statement-and-multiple-properties/112685/6 "2024-07-24T17:38:50Z")

</div>

@KJoy3 could you try this?

if([properties.distribution\_frequency]= “Annual”, [properties.last\_investor\_update]+31536000000,0)+if([properties.distribution\_frequency]= “Quarterly”, [properties.last\_investor\_update]+7776000000,0)+if([properties.distribution\_frequency]=“Bi-Annual”, [properties.last\_investor\_update]+15552000000,0)

The if statement is missing the specification what should be returned when it’s not true, adding a 0 for that scenario should work.

---

<div class="post-metadata">

**Author:** ![KJoy3](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@KJoy3](https://community.hubspot.com/u/KJoy3)\
**Post date:** [July 24, 2024, 6:05pm UTC](https://community.hubspot.com/t/creating-a-function-using-an-if-then-statement-and-multiple-properties/112685/7 "2024-07-24T18:05:18Z")

</div>

That did the trick!! Thank you so much Karsten! I really appreciate you workshopping this with me.

---

<div class="post-metadata">

**Author:** ![Abrabomer](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@Abrabomer](https://community.hubspot.com/u/Abrabomer)\
**Post date:** [December 17, 2024, 11:26am UTC](https://community.hubspot.com/t/creating-a-function-using-an-if-then-statement-and-multiple-properties/112685/8 "2024-12-17T11:26:49Z")

</div>

I’ve run into something similar before. In Excel, I would use an IF statement to adjust dates based on a condition, and it looks like you’re trying to do something very similar with the “Frequency” property. In your case, you could try using a custom formula in your tool (assuming you’re working with a platform like Airtable or [Monday.com](http://Monday.com)) to check the value of “Frequency” and then adjust the “Next Update Date” accordingly. For example, you could use something like IF(Frequency = “Annual”, DateAdd(Last\_Investor\_Update, 365, “days”), DateAdd(Last\_Investor\_Update, 90, “days”)). It might need some tweaks, but it should get the job done.

---

<div class="post-metadata">

**Author:** ![Abrabomer](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@Abrabomer](https://community.hubspot.com/u/Abrabomer)\
**Post date:** [December 17, 2024, 1:15pm UTC](https://community.hubspot.com/t/creating-a-function-using-an-if-then-statement-and-multiple-properties/112685/9 "2024-12-17T13:15:50Z")

</div>

In your case, you could try using a custom formula in your tool (assuming you’re working with a platform like Airtable or [Monday.com](http://Monday.com)) to check the value of “Frequency” and then adjust the “Next Update Date” accordingly. For example, you could use something like IF(Frequency = ““Annual””, DateAdd(Last\_Investor\_Update, 365, ““days””), DateAdd(Last\_Investor\_Update, 90, ““days””)). It might need some tweaks, but it should get the job done.By the way, if you ever want to dive deeper into formula auditing (like I did when learning Excel), I found this [Sheetcast](https://sheetcast.com/turbotools/turbo-trace/show-formulas-in-excel) guide super helpful. It helped me better understand how to apply formulas more effectively.
