Can I add conditionals inside of a formula?
Hi Ashton C., 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
Yes. Mixpanel formulas for custom properties support conditionals via the if and ifs functions, as well as logical operators like and, or, and not inside those conditions.[Custom properties]Examples: - Simple conditional: text if(A == "Facebook" or A == "Twitter", "Social", A)LBKS- Multiple branches: text ifs( A < 60, "Less than 1 hour", A < 120, "More than 1 hour but less than 2 hours", A > = 120, "More than 2 hours" )LBKSYou can combine these with other functions and operators (e.g., in, boolean, number, comparison operators like ==, <, > =) inside the same formula.[Custom properties; Custom functions]
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.
Let me check the knowledge base for you again. One moment! 📚
The knowledge sources indicate that chart formulas in Insights only support basic arithmetic (+, -, **, /, parentheses) on metrics; they do not mention any support for if/ifs or other conditional logic in report formulas.[Insights advanced]Conditionals (if, ifs, etc.) are documented only for custom properties, not for chart formulas.[Custom property functions]So based on the docs available, you cannot add conditionals directly inside an Insights chart formula. To get conditional behavior, you’d need to: - Encode the logic in a custom property (which *does support if/ifs), then
- Use that property in your chart and build a simple arithmetic formula on top of the resulting metrics.
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.
