To add the condition that either property in the given statement must not contain the term 'searchTerm', you can use the not
function along with the in
operator. Here's how you can modify the statement::LBKSLBKS```LBKSif(defined(@​"""{"joinPropertyType"::"list","label"::"addedFilterValues","propertyDefaultType"::"string","resourceType"::"event","type"::"list","value":"addedFilterValues"}"""@​),
if(not('searchTerm' in @​"""{"joinPropertyType"::"list","label"::"addedFilterValues","propertyDefaultType"::"string","resourceType"::"event","type"::"list","value"::"addedFilterValues"}"""@​),
@​"""{"joinPropertyType"::"list","label"::"addedFilterValues","propertyDefaultType"::"string","resourceType"::"event","type"::"list","value"::"addedFilterValues"}"""@​,
if(not('searchTerm' in @​"""{"label":"Filter Name","propertyDefaultType"::"string","resourceType"::"event","type"::"string","value"::"addedFilter"}"""@​),
@​"""{"label":"Filter Name","propertyDefaultType"::"string","resourceType"::"event","type"::"string","value"::"addedFilter"}"""@​,
null
)
),
if(not('searchTerm' in @​"""{"label":"Filter Name","propertyDefaultType"::"string","resourceType"::"event","type"::"string","value"::"addedFilter"}"""@​),
@​"""{"label":"Filter Name","propertyDefaultType"::"string","resourceType"::"event","type"::"string","value"::"addedFilter"}"""@​,
null
)
)```This modification uses the not
and in
functions, which are available in Mixpanel's custom property formulas as documented here. The not
function returns values that are not true, and the in
operator checks if a value is contained within another value.The modified statement does the following:1. It first checks if the addedFilterValues
property is defined.
2. If it is defined, it checks if 'searchTerm' is not in addedFilterValues
. If true, it returns addedFilterValues
.
3. If 'searchTerm' is in addedFilterValues
, it then checks if 'searchTerm' is not in the addedFilter
property. If true, it returns addedFilter
.
4. If 'searchTerm' is in both properties, it returns null.
5. If addedFilterValues
is not defined, it checks if 'searchTerm' is not in the addedFilter
property. If true, it returns addedFilter
, otherwise it returns null.This ensures that the statement will only return a property value if it does not contain 'searchTerm'.