Calculation Property

Hi,
For context, we have specific rules we follow in attributing our contacts and deals. We base our deal attribution based on the outcome of a stamped value on the first associated contact on a deal.
To keep it short we have a contact calculated property, once a deal is created and that contact is the first associated contact, we copy over the current value of the contact calculated property to a deal property that stores our attribution for that deal (i.e. Sales or Marketing).
We now have to update our logic on the said contact calculated property and I don’t seem to make it work. Hoping a genius might find this thread and provide guidance.
We want the logic to be
IF Original Source is Organic Search, Organic Social, or Direact Traffic, then “Marketing”, if not will check
IF time between Contact Create date and Deal Create Date < 90 days,

check If Original Source is Offline, then “Sales”, else “Marketing”,
if not check Marketing Score > Sales Score, “Marketing”, “Sales”
Sharing below the formula:
if(
([properties.hs_analytics_source] == “DIRECT” || [properties.hs_analytics_source] == “ORGANIC”),
“Marketing”,
if(
time_between([properties.createdate], [properties.lastmodifieddate]) < 7776000000,
if([properties.hs_analytics_source] == “OFFLINE”, “Sales”, “Marketing”),
if(
is_known([properties.marketing_attribution_score]) && is_known([properties.attribution_test___marketing]),
if([properties.marketing_attribution_score] >= [properties.attribution_test___marketing], “Marketing”, “Sales”),
if(
is_known([properties.marketing_attribution_score]),
“Marketing”,
if(
is_known([properties.attribution_test___marketing]),
“Sales”, “Marketing” )))))
My problem is that if the time between Contact Create date and Deal Create Date > 90 days,
I could not seem to override the formula to always result to Marketing if Original Source is Direct or Organic, despite making it as the first rule/condition.
Hoping for guidance from the community.
Thank you.

Hi @marie9423498,

Thanks for providing the example and details up front. I think you’re pretty close, but I’ve run into similar quirks when trying to nest conditions like this, especially with calculated properties and HubSpot’s handling of source values.

The main issue sounds like it’s tied to how the formula is evaluating that first condition (I think). Even though you’ve placed the Direct/Organic check up top, the way the logic flows means it might still be falling through to the rest of the tree, especially if one of the dependent properties (like a score or timestamp) isn’t known.

Try this:

if(
 [properties.hs_analytics_source] == "DIRECT" || 
 [properties.hs_analytics_source] == "ORGANIC_SEARCH" || 
 [properties.hs_analytics_source] == "ORGANIC_SOCIAL", 
 "Marketing", 
 if(
 time_between([properties.createdate], [properties.attribution_deal_create_date]) < 7776000000, 
 if(
 [properties.hs_analytics_source] == "OFFLINE", 
 "Sales", 
 "Marketing"
 ), 
 if(
 is_known([properties.marketing_attribution_score]) && is_known([properties.attribution_test___marketing]), 
 if(
 [properties.marketing_attribution_score] >= [properties.attribution_test___marketing], 
 "Marketing", 
 "Sales"
 ), 
 if(
 is_known([properties.marketing_attribution_score]), 
 "Marketing", 
 if(
 is_known([properties.attribution_test___marketing]), 
 "Sales", 
 "Marketing"
 )
 )
 )
 )
)

If this doesn’t work as intended, let me know and I’m happy to help troubleshoot further.

Josh

Hi Josh,
Thank you for coming to the rescue, truly appreciate it.
I did tested the formula you suggested, however the 90 days logic still overrides even if the Original Source is Direct/Organic.
Attached is the screenshot of the test. The scenario is even if the deal create date is more than 90 days of the contact create date, but since original source is “Organic Social”, the output should have been “Marketing”, but the formula still seems to refer to the greater score between Marketing Attribution Scorevs Sales Attribution Score.

Hi @marie9423498,

Let’s try a couple of other things. It is a bit difficult to troubleshoot on my side because I don’t have the exact properties.

Can you check the internal property names of the sources- (these do need to match exactly)?

  • ORGANIC_SOCIAL might actually be SOCIAL_MEDIA
  • DIRECT should be DIRECT_TRAFFIC
  • Etc. - these do need to match exactly

If it still isn’t working I think we’ll want to break the formula down a into segments to see where it’s failing.

Hi Josh,
Truly appreciate for going through with me on this.
This has solved the problem and the formula now works.
Regards,

Marie