am I able to calculate extended item price using only existing price and quantity field
Hi Ryan D., 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 calculate an extended item price (total price) in Mixpanel by creating a custom property that multiplies the price and quantity fields. This is a perfect use case for Mixpanel's Custom Properties feature.You can create a custom property with a simple formula that multiplies your existing price and quantity fields together. Here's how you would do it: 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. Give your property a name (like "Total Price" or "Extended Price") 4. In the formula field, enter a multiplication formula using your existing properties:
```LBKSLBKSWhere `<price> ` and `<quantity> ` are your existing event properties.LBKSThis is specifically mentioned in the documentation as a common use case: "If you have an e-commerce app, you can combine 'price' and 'quantity' properties into a 'total price' property" [Custom Properties: Calculate new properties on the fly](https://docs.mixpanel.com/docs/features/custom-properties).LBKSYou can also use the `let` function for more complex calculations if needed: LBKS```LBKSlet(
spend, <price> ** <quantity> ,
spend
)LBKS```LBKSLBKSThe custom property will be local to your report by default. If you're on a Growth or Enterprise plan, you can save it globally for reuse in other reports by clicking "Save" instead of "Apply".
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.
Price is a sub property of the products array and it will not let me select it.
Let me check the knowledge base for you again. One moment! 📚
I understand your challenge - you're trying to access a price property that's nested within a products array, and Mixpanel isn't letting you select it directly in your custom property formula.This sounds like you're working with a list of objects property structure. Mixpanel does support list of objects, but accessing nested properties within them for calculations requires specific handling.For your specific case, you have a few options: 1. Use the map and sum functions: If you need to calculate the total price across all products in the array, you can use a combination of the map
and sum
functions: LBKSsum(map(item, products, item.price ** item.quantity))LBKS
This would iterate through each item in your products array, multiply the price by quantity for each, and then sum the results.2. Access a specific item: If you need to access just one specific item in the array, you can use an index: LBKSproducts[0].price ** products[0].quantityLBKS
This would calculate the extended price for just the first product in the array.The Mixpanel documentation mentions that "The same syntax works with objects" when discussing how to query a list with an index Custom Properties: Calculate new properties on the fly.If you're still having trouble, you might want to check if your property structure is properly formatted as a list of objects. In Mixpanel, a list of objects property should be structured as an array of JSON objects.
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.