0

I'm trying to set up some custom filters to combine data from a few sources, using Calculated Dimensions.

I'm able to create a single filter using:

IF([Web_Analytics_Site_Campaign] contains 'registration','Spring Registration',

However if I try to add a second dimension using the AND function, it fails or ignores the code.

IF([Web_Analytics_Site_Campaign] contains AND('registration','fall'),'Fall Registration',

Not sure if I'm not reading the suggested function incorrectly or there's some odd typo I'm missing.

2 Answers 2

0

The AND function in Datorama is used to check if multiple conditions are met, not to check if a string contains multiple substrings. To check if a string contains multiple substrings, you can nest multiple IF statements or use regular expressions.

Here's an example of how you could use nested IF statements:

IF([Web_Analytics_Site_Campaign] contains 'registration'
    AND [Web_Analytics_Site_Campaign] contains 'fall',
    'Fall Registration',
IF([Web_Analytics_Site_Campaign] contains 'registration'
    AND [Web_Analytics_Site_Campaign] contains 'spring',
    'Spring Registration',
'Other'))

Alternatively, here's an example of how you could use regular expressions to check if a string contains multiple substrings:

IF(REGEX_MATCH([Web_Analytics_Site_Campaign], '.*registration.*(fall|spring).*'),
    IF(REGEX_MATCH([Web_Analytics_Site_Campaign], '.*registration.*fall.*'), 'Fall Registration', 'Spring Registration'),
'Other')
2
  • Thanks @gvgramazio! This looks a lot more like I expected it would. I was trying something like this but didn't have any luck. However, this is kicking back an error I believe due to the syntax. IF([Message_Send_Name] contains 'registration','Registration', IF([Web_Analytics_Site_Campaign] contains 'registration','Registration', IF([Web_Analytics_Site_Campaign] contains 'registration' AND [Web_Analytics_Site_Campaign] contains 'fall', 'Fall Registration', 'Other')) Malformed expression Expected ")":5:5, found "AND WEB_AN"
    – jdblundell
    Feb 12 at 20:55
  • Sorry for the poor formatting. tried to edit it and apparently there's a 5 minute delay. I tried looking for the documentation on this as well but didn't have any luck. If you have a link to some documentation that would be a huge help as well.
    – jdblundell
    Feb 12 at 21:02
-2

please use below code.. let me know if you able to solve -

IF( Contains([Web_Analytics_Site_Campaign], 'registration') AND Contains([Web_Analytics_Site_Campaign], 'fall'), 'Fall Registration', IF( Contains([Web_Analytics_Site_Campaign], 'registration') AND Contains([Web_Analytics_Site_Campaign], 'spring'), 'Spring Registration', 'Other' ) )

1
  • 2
    This is the same as the existing answer, just with less information. Code dumps are not very good answers. The explanation is as important as the solution itself.
    – Derek F
    Aug 23 at 11:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .