Can I merge the strings in a list of string property into one string property using custom event property feature?
Hi Sharon L., 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, you can merge strings from a list property into a single string property using Mixpanel's Custom Properties feature.
Custom Properties allows you to combine existing properties into new properties on the fly using a formula language similar to Excel. For list properties specifically, you can use functions like string concatenation to join the elements.
Here's how you could approach this:
1. If you have a list of strings, you can use indexing to access individual elements and then concatenate them using the + operator.
For example, if you have a list property called "recommendations", you could extract and concatenate elements like this:
recommendations[0] + " " + recommendations[1]
This approach is mentioned in the documentation where it shows how to query a list with an index:
"Let's say you have a list of recommendations as a property, and you'd like to parse out the first recommendation as another string property."
Custom Properties documentation explains that the + operator can be used for string concatenation:
"+: Addition. Operator can also be used to create string concatenation, for example: "string_to_concatenate" + your string property"
To create a custom property: 1. Click the plus button to the right of the search bar 2. Select Event Property or User Property to open the property builder 3. Name your property and write your formula in the formula bar 4. Click Apply to use it locally in your report, or Save to make it available for other reports
Note that free plan users can only create custom properties locally within a report, while Growth and Enterprise plan users can save them globally for reuse across reports.
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! ๐
Yes, Mixpanel's Custom Properties feature offers several functions that allow you to write smarter conditions when merging strings or manipulating data. Here are some of the most useful functions for creating conditional logic:
Conditional Functions
- if: Basic conditional that evaluates if an expression is true or false
if(condition, value if true, value if false)
Example: if(A=="Facebook" or A=="Twitter", "Social", A)
- ifs: Runs multiple checks and returns the value corresponding to the first true condition
ifs(condition1, value1, condition2, value2, ...)
Example: ifs(A<60, "Less than 1 hour", A<120, "More than 1 hour but less than 2 hours", A> =120, "More than 2 hours")
List Processing Functions
For working with your list of strings, these functions are particularly useful:
- any: Returns TRUE if the given expression is true for any value in the list
any(name, list, expr)
- all: Returns TRUE if the given expression is true for all values in the list
all(name, list, expr)
- filter: Filters the list to only include items for which the expression is true
filter(name, list, expr)
- map: Transforms each value in the list using the given expression
map(name, list, expr)
Example: map(X, states, lower(X)) โ transforms ["Georgia","Florida","Texas"] to ["georgia","florida","texas"]
- sum: Sums all numbers in a given list (ignores non-numeric items)
sum(list)
String Manipulation Functions
- regex_match: Returns true if a pattern matches any part of a string - regex_extract: Extracts matching portions from a string - regex_replace: Replaces parts of a string that match a pattern - split: Splits a string into different parts based on a delimiter
Variable Definition
- let: Define a variable and use it in an expression to keep your custom property definition neat
let(name, definition, expression)
These functions can be combined to create sophisticated conditions for processing your list of strings before merging them into a single string property.
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! ๐
I'll create a custom property formula that concatenates strings in a list with a comma separator, handling lists with 0-3 elements.
Here's a formula that will work for your use case:
```
ifs( len(your_list_property) == 0, "", len(your_list_property) == 1, your_list_property[0], len(your_list_property) == 2, your_list_property[0] + "," + your_list_property[1], len(your_list_property) == 3, your_list_property[0] + "," + your_list_property[1] + "," + your_list_property[2], TRUE, "" )
LBKSThis formula uses:
- The `len()` function to determine the length of your list
- The `ifs()` function to handle different cases based on the list length
- List indexing with `your_list_property[0]`, etc. to access individual elements
- The `+` operator for string concatenation with commas as separators
Replace `your_list_property` with the actual name of your list property in Mixpanel.
To implement this custom property:
1. Click the plus button next to the search bar in your report
2. Select Event Property or User Property
3. Name your property (e.g., "ConcatenatedList")
4. Paste the formula above, replacing `your_list_property` with your actual list property name
5. Click Apply to use it locally or Save to make it available for reuse
[Custom Properties documentation](https://docs.mixpanel.com/docs/features/custom-properties) provides more details on creating and using custom properties in Mixpanel.
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.
