Mixpanel Community Icon

Syntax Error in Undefined Check for Corrected UTM Source

·
·

what is wrong about this syntax? I want to check if the “corrected utm source” property is not defined: IF(UNDEFINED(Corrected UTM Source),TRUE,FALSE)

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Hi Elena M., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> 👋

    Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    There are a few issues with your syntax for checking if the "Corrected UTM Source" property is not defined in Mixpanel: 1. The function name should be lowercase if instead of uppercase IF 2. The correct function to check if a property is defined is defined(), not UNDEFINED() 3. You should not use backticks () around property names in Mixpanel expressions 4. Property names should be referenced using the properties["Property Name"]syntaxLBKSThe correct syntax would be: LBKSLBKS```LBKSif(not defined(properties["Corrected UTM Source"]), true, false)LBKS```LBKSLBKSOr more simply: LBKSLBKS```LBKSnot defined(properties["Corrected UTM Source"])LBKS```LBKSLBKSThis is because thedefined()function already returns a boolean value, so wrapping it in an if statement that returns true/false is redundant.LBKSAccording to the Mixpanel documentation on segmentation expressions, thedefined()function "determines if a value exists. If a property is not defined on a parent event or profile, this will return false, otherwise this will return true." [Custom Properties](https://docs.mixpanel.com/docs/features/custom-properties#functions)LBKSThenotoperator can be used to negate the result of thedefined()` function, returning true when the property is not defined.

    kapa.ai is still learning and improving, please let me know how I did by reacting below.

    ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.