how can i apply string operations like length count on property filters?
Hi Tobias, 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
You can’t apply arbitrary string functions directly inside standard report filter UI fields, but there are two supported ways to do “length/count”-style string logic based on the docs:
1. Use a Custom Property with len, left, right, mid, split, etc.
Create a Custom Property that computes what you need, then filter on that new property.For example, to get the length of a string property A: text len(A)LBKSlen returns the length of a string (or list), so this custom property becomes numeric and can be used in filters and breakdowns (e.g. len(A) > 10).[Custom property functions]Other useful string operations in custom properties: - left(A, 3) – first 3 characters
- right(A, 3) – last 3 characters
- mid(A, 1, 4) – substring from position 1, length 4
- split(A, "/", 2) – 2nd piece after splitting on /[Custom property functions]You then use this custom property in any report filter as you would a normal property.
2. Use Segmentation Expressions in the Query API (advanced)
If you are using the Query API (/segmentation, /funnels with where / on), you can write an expression (not just a simple equals filter) using the expression grammar. Supported operations include: - arithmetic: + - ** / %
- comparisons: == != > > = < <=
- logical: and or not
- regex / in
- typecasts: boolean() number() string()
- floor, round, ceil<https://github.com/mixpanel/docs/blob/main/reference/Mixpanel%20APIs/segmentation-expressions.md|[Segmentation expressions>]However, in the segmentation-expression grammar there is no len() or substring function documented, so you cannot directly compute string length there; you would still need to precompute length (e.g., as a property or via custom properties in the UI) and then reference that numeric property in the where clause.---So to “apply string operations like length count on property filters” in the UI: define a *Custom Property using len, left, right, mid, or split, then filter on that derived property. There is no direct len() in plain filter fields or in segmentation-expression grammar per the provided docs.
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.
