Mixpanel Community Icon

Merge List of Strings into One Using Custom Event Property

·
·

Can I merge the strings in a list of string property into one string property using custom event property feature?

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

    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

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

    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: LBKSrecommendations[0] + " " + recommendations[1]LBKSThis 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 reportsNote 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.

  • Avatar of Sharon L.
    Sharon L.
    ·
    ·

    kapa.ai Is there available functions to write smarter condition?

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

    Let me check the knowledge base for you again. One moment! 📚

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

    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

    ```LBKS Example: `if(A=="Facebook" or A=="Twitter", "Social", A)`LBKS- **ifs**: Runs multiple checks and returns the value corresponding to the first true condition ```LBKS ifs(condition1, value1, condition2, value2, ...) ```LBKS 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")`LBKS[Custom Properties documentation](https://docs.mixpanel.com/docs/features/custom-properties#functions)

    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

    ```LBKSLBKS- **all**: Returns TRUE if the given expression is true for all values in the list ```LBKS all(name, list, expr) ```LBKSLBKS- **filter**: Filters the list to only include items for which the expression is true ```LBKS filter(name, list, expr) ```LBKSLBKS- **map**: Transforms each value in the list using the given expression ```LBKS map(name, list, expr) ```LBKS Example: `map(X, states, lower(X))` → transforms ["Georgia","Florida","Texas"] to ["georgia","florida","texas"]LBKS- **sum**: Sums all numbers in a given list (ignores non-numeric items) ```LBKS 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

    ```LBKSLBKSThese functions can be combined to create sophisticated conditions for processing your list of strings before merging them into a single string property.LBKS[Custom Properties Functions Reference](https://docs.mixpanel.com/docs/features/custom-properties#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.

  • Avatar of Sharon L.
    Sharon L.
    ·
    ·

    kapa.ai Write me a custom property formula that automatically concat strings in a list with “,” symbol. The string count could be 0-3.

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

    Let me check the knowledge base for you again. One moment! 📚

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

    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: LBKSifs( 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 separatorsReplace 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 reuseCustom Properties documentation 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.