Participant

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

SOLVE

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!

1 Accepted solution
Solution
Hall of Famer | Partner

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

SOLVE

@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.

 Karsten KöhlerHubSpot Freelancer | RevOps & CRM Consultant | Community Hall of FamerBeratungstermin mit Karsten vereinbaren

 Did my post help answer your query? Help the community by marking it as a solution.
6 Replies 6
Hall of Famer | Partner

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

SOLVE

Hi @KJoy3,

Yes, you should be able to do this with a calculation property: 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: 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!

 Karsten KöhlerHubSpot Freelancer | RevOps & CRM Consultant | Community Hall of FamerBeratungstermin mit Karsten vereinbaren

 Did my post help answer your query? Help the community by marking it as a solution.
Participant

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

SOLVE

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)

Hall of Famer | Partner

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

SOLVE

@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.

 Karsten KöhlerHubSpot Freelancer | RevOps & CRM Consultant | Community Hall of FamerBeratungstermin mit Karsten vereinbaren

 Did my post help answer your query? Help the community by marking it as a solution.
Participant

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

SOLVE

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

Solution
Hall of Famer | Partner

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

SOLVE

@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.

 Karsten KöhlerHubSpot Freelancer | RevOps & CRM Consultant | Community Hall of FamerBeratungstermin mit Karsten vereinbaren

 Did my post help answer your query? Help the community by marking it as a solution.
Participant

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

SOLVE

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