Mixpanel Community Icon

Calculating the 95th Percentile: A Step-by-Step Guide

·
·

How can I calculate the percentile 95 of specific measure? (I can find p90 and p99 and there’s no p95)?

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

    Hi Yulia 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
    ·
    ·

    To calculate the 95th percentile of a specific measure in Mixpanel, you have a couple of options: 1. In Insights reports: Mixpanel's Insights report allows you to calculate percentiles, including the 95th percentile. When using the "Aggregate Property" or "Aggregate Property per User" measurements, you can select the "Percentiles" aggregation option. However, the default options only include 25th, 75th, 90th, and 99th percentiles. The 95th percentile is not directly available in this UI. Mixpanel Docs: Insights Measurements mentions these percentile options but doesn't include the 95th percentile.2. Using JQL (JavaScript Query Language): If you need the exact 95th percentile, you can use Mixpanel's JQL to calculate it. JQL provides more flexibility in specifying custom percentiles. Here's an example of how you can calculate the 95th percentile using JQL:

    return Events({ from_date: "2023-01-01", to_date: "2023-12-31", event_selectors: [{event: "your_event_name"}], }) .reduce(mixpanel.reducer.numeric_percentiles( "properties.your_property_name", [95])); } ```LBKSLBKS This code will return the 95th percentile for the specified property of your chosen event.LBKS [Mixpanel Docs: JQL Builtins](https://docs.mixpanel.com/docs/reports/apps/jql#mixpanelreducernumeric_percentilesaccessor-percentiles-spec) shows how to use the `numeric_percentiles` reducer to calculate custom percentiles.LBKSRemember to replace "your_event_name" and "your_property_name" with the actual event and property you want to analyze, and adjust the date range as needed.LBKSUsing JQL gives you the flexibility to calculate any specific percentile you need, including the 95th percentile, which is not directly available in the standard Insights UI.

    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 Yulia M.
    Yulia M.
    ·
    ·

    kapa.ai Can I make the dates by default min and max by the date?

  • 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
    ·
    ·

    To answer your question about setting default dates to the minimum and maximum dates in Mixpanel, I'll need to provide some context and clarification.Mixpanel doesn't have a built-in feature to automatically set the date range to the absolute minimum and maximum dates of your data by default. However, there are some options you can consider: 1. Date Range Selector: Mixpanel provides a date range selector that allows you to choose from preset options or select a custom date range. The default is usually set to "Last 30 days" in most reports. Mixpanel Docs: Date Range explains the various preset options and how to select custom date ranges.2. Custom Date Range: You can manually set a very wide date range to encompass all your data. For example, you could set the start date to a time before you started collecting data and the end date to today or a future date.3. JQL Queries: If you're using JQL (JavaScript Query Language) for custom queries, you have more flexibility. You could potentially write a query that first determines the min and max dates in your data and then uses those for the main query. However, this would be a custom solution and not a default setting.4. API or Data Export: If you're accessing data via Mixpanel's API or exporting data, you might be able to determine the full date range of your data and use that information in your queries or analysis.It's important to note that Mixpanel doesn't provide a direct way to automatically set the default date range to the absolute min and max dates of your entire dataset across all reports. The date range typically needs to be set manually or programmatically for each query or report.If you need this functionality consistently, you might want to consider creating a custom solution using Mixpanel's API or JQL, or reaching out to Mixpanel's support team to suggest this feature for future updates.

    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 Yulia M.
    Yulia M.
    ·
    ·

    kapa.ai it’s writes me that the main in unexcepted variable

  • 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 apologize, but I need more context to understand your issue fully. It seems you're encountering an error message related to the main function in a JQL (JavaScript Query Language) query for Mixpanel. The error "main is unexpected variable" suggests there might be a syntax error in your JQL code.To help you resolve this, let's review the correct structure for a JQL query in Mixpanel: LBKSfunction main() { // Your query code goes here return Events({ // Event parameters }) // Additional transformations and reducers }LBKSThe main() function is crucial in JQL queries. As stated in the Mixpanel JQL documentation: "The JQL JavaScript code must define a main() function. This JavaScript will be compiled, and the main() function will be executed by the query engine."Here are a few things to check: 1. Make sure you've defined the main function correctly. 2. Ensure that your function is named main (all lowercase). 3. Check that you haven't accidentally used main as a variable name elsewhere in your code. 4. Verify that your JQL query is properly formatted and all parentheses, brackets, and braces are correctly matched.If you're still encountering issues, it would be helpful if you could provide the exact JQL code you're trying to run. This would allow me to identify the specific problem and provide a more targeted solution.Remember, JQL is a powerful tool in Mixpanel, but it requires careful syntax. If you're new to JQL, you might want to start with some of the examples provided in the Mixpanel documentation and gradually build up to more complex queries.

    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 Yulia M.
    Yulia M.
    ·
    ·

    kapa.ai function main() { return Events({ from_date: “2023-01-01”, to_date: “2023-12-31", event_selectors: [{event: “agent-video”}], }) .reduce(mixpanel.reducer.numeric_percentiles( “properties.your_property_name”, [95])); } i use this code, and it doesn’t work

  • 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 understand you're having trouble with the JQL code you've provided. Let's take a closer look at the issue and make some adjustments to help it work correctly.The structure of your code is correct, but there's one key element that needs to be changed. In the numeric_percentiles reducer, you're using a placeholder property name instead of an actual property from your event data. Here's how we can fix it: 1. Replace "properties.your_property_name" with the actual property name you want to analyze. This should be a numeric property associated with your "agent-video" event.Here's an example of how your corrected code might look: LBKSfunction main() { return Events({ from_date: "2023-01-01", to_date: "2023-12-31", event_selectors: [{event: "agent-video"}], }) .reduce(mixpanel.reducer.numeric_percentiles( "properties.duration_seconds", [95])); }LBKSIn this example, I've replaced "properties.your_property_name" with "properties.duration_seconds", assuming you want to calculate the 95th percentile of the video duration. You should replace "duration_seconds" with the actual name of the numeric property you want to analyze.Some things to keep in mind: 1. Make sure the property you're using exists in your "agent-video" event and contains numeric values. 2. Double-check that "agent-video" is the correct event name in your Mixpanel project. 3. Verify that you have data for this event within the specified date range (January 1, 2023 to December 31, 2023).If you're still encountering issues after making these changes, it would be helpful to know the specific error message you're receiving. Also, you might want to use the Mixpanel JQL Debugger to help identify any problems with your query.Remember, JQL is case-sensitive, so make sure your event names and property names match exactly with what's in your Mixpanel project.Mixpanel Docs: JQL Builtins provides more examples and details on using the numeric_percentiles reducer if you need further reference.

    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 Yulia M.
    Yulia M.
    ·
    ·
  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Sorry Yulia M., it looks like your question contains files, which I cannot process. Please reformulate your question without including any files.

  • Avatar of Yulia M.
    Yulia M.
    ·
    ·

    kapa.ai can you explain me where I insert this code?

  • 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
    ·
    ·

    Certainly! I understand you're asking about where to insert the JQL (JavaScript Query Language) code in Mixpanel. Here's where you can use this code: 1. JQL Interface: The primary place to insert and run JQL code is in Mixpanel's JQL interface. You can access this by: a. Log into your Mixpanel account b. Go to the "Apps" section in the left sidebar c. Click on "JQL" (JavaScript Query Language) Here, you'll find a code editor where you can paste your JQL script. Mixpanel Docs: JQL provides more information about accessing and using the JQL interface.2. API Endpoint: If you're using Mixpanel programmatically, you can send JQL queries to the JQL API endpoint. Here's an example using curl:

    sh curl [https://mixpanel.com/api/query/jql](https://mixpanel.com/api/query/jql) \ -u YOUR_API_SECRET: \ --data-urlencode script@​my_query.js ```LBKSLBKS This method is described in the [Mixpanel Query API documentation](https://github.com/mixpanel/docs/blob/main/reference/Query%20API/jql/query-jql.md).LBKSRemember, JQL is a powerful tool for custom queries in Mixpanel, but it requires some familiarity with JavaScript and Mixpanel's data structure. If you're new to JQL, it might be easier to start with the web interface before moving to API calls.LBKSAlso, make sure you have the necessary permissions in your Mixpanel project to run JQL queries. If you're having trouble accessing JQL, you might need to check with your project administrator.

    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 Yulia M.
    Yulia M.
    ·
    ·

    kapa.ai How to use this custom measure JQL in charts?

  • 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
    ·
    ·

    To use a custom measure created with JQL in Mixpanel charts, you'll need to follow a specific process. Unfortunately, there isn't a direct way to use JQL queries in standard Mixpanel charts. However, you can create a custom event or property based on your JQL query and then use that in your charts. Here's how you can approach this: 1. Create a Custom Event or Property: First, you need to create a custom event or property based on your JQL query. This is done using Mixpanel's Custom Events feature. Mixpanel Docs: Custom Events explains how to create custom events. You can use your JQL query as the basis for defining the custom event.2. Use the Custom Event in Charts: Once you've created a custom event or property, you can use it in your Insights reports and other Mixpanel charts just like any other event or property. Mixpanel Docs: Insights provides information on how to use events and properties in Insights reports.3. Limitations: It's important to note that this method has some limitations. Custom events are calculated periodically, not in real-time, and there may be some delay in data updates.4. Alternative: Data Pipelines: For more complex scenarios or real-time needs, Mixpanel recommends using their Data Pipelines feature to export your data to a data warehouse where you can perform custom calculations and then import the results back into Mixpanel. Mixpanel Blog: Data Pipelines mentions this feature as an alternative for running arbitrary queries on your Mixpanel events.Remember, JQL is primarily a tool for ad-hoc analysis and data exploration. For recurring reports and visualizations, it's generally better to use Mixpanel's built-in reporting features or create custom events/properties based on your JQL insights.If you need more specific guidance on implementing this for your particular use case, I'd recommend reaching out to Mixpanel's support team for personalized assistance.

    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 Yulia M.
    Yulia M.
    ·
    ·

    kapa.ai which custom event I should create? after I created my JQL MEASURE

  • 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
    ·
    ·

    Based on your previous JQL query and the context of our conversation, it seems you're trying to create a custom event to capture the 95th percentile of a specific measure (likely related to the "agent-video" event) in Mixpanel. Here's how you can approach creating a custom event for this purpose: 1. Custom Event Creation: You should create a custom event that represents the 95th percentile of the measure you're interested in. For example, if you were measuring video duration, you might name your custom event something like "95th Percentile Agent Video Duration".To create this custom event: 1. Go to the Lexicon in your Mixpanel project. 2. Click on the "Custom Events" tab. 3. Click "Create Custom Event". 4. Name your event (e.g., "95th Percentile Agent Video Duration"). 5. In the definition, you'll use your JQL query. It might look something like this: LBKSfunction main() { return Events({ event_selectors: [{event: "agent-video"}] }) .reduce(mixpanel.reducer.numeric_percentiles( "properties.duration_seconds", [95])); }LBKSReplace "duration_seconds" with the actual property name you're measuring.Mixpanel Docs: Custom Events provides detailed instructions on how to create and manage custom events.Remember, custom events based on JQL queries are not calculated in real-time. Mixpanel typically updates these daily, so there may be a delay in seeing the most recent data.After creating this custom event, you'll be able to use it in your Insights reports and other Mixpanel charts. You can select it just like any other event when creating your reports.Keep in mind that this custom event will give you a single value (the 95th percentile) for your entire dataset. If you need to break this down by time or other properties, you might need to adjust your approach or consider using Mixpanel's Data Pipelines feature for more complex analyses.

    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.