Solved

Average of Custom Formula using Multiple Properties

  • 19 December 2022
  • 3 replies
  • 328 views

Badge

I have an event with multiple properties and want to be able to graph the daily average of a formula that includes both of those events. To be specific, I have an event that has a shoppingTimeInSeconds property and a numberOfUnits property. I want a graph that charts the daily average of this units per hour formula: 

3600.00 / (shoppingTimeInSeconds / numberOfUnits)

I have not been able to find a way of accomplishing this other than by sending a unitsPerHour property along with the event that is already calculated before being sent to Amplitude.

icon

Best answer by Loc Tran 23 December 2022, 19:03

View original

3 replies

Userlevel 2
Badge +5

Hi Michael, 

There is a Formula Metric view in the event segmentation chart which will let you create custom formulas to analyze the event properties that belong to the same event. Here’s a link to the help center article with more details on custom formulas. 

If you are using numerical properties only and you want to see the average, I can also suggest the Properties Metric view and the dropdown for “average of property value”. I don’t want to share any of your account-specific information here in the community forums, so I made an example chart using AmpliTunes demo data. Just imagine your data in place of the 2 events on the left. 

Chart linkhttps://analytics.amplitude.com/demo/chart/new/y9fnnju

I set this to the hourly view and the takeaway on the right side of the chart to “Average Value” (using the 3 dots for “more”).

To find your unitsPerHour metric, I think you can divide the two averages. It would be the average of TimeInSeconds divided by the average of numberOfUnits

Let me know if you have questions! Thanks! ​​​​​​​

Best, 
Loc 

 

Badge

Hi @Loc Tran. I’ve looked over your response and I don’t think it answers my question…

I am aware of the Formula Metric view in the event segmentation chart, but I don’t see a way of achieving what I outlined. I am also aware of the Properties Metric view that allows you to see the “average of property value”, which is why in my original post I said “I have not been able to find a way of accomplishing this other than by sending a unitsPerHour property along with the event that is already calculated before being sent to Amplitude.” 

Towards the end of your response, you said that you’re not sure but you think I can divide the two averages of the “TimeInSeconds” property and the “numberOfUnits” property. This is true, but it does not answer my question or solve my problem. I need Amplitude to calculate the unitsPerHour of each event and then graph the daily average of those calculations. Is this possible?

Userlevel 2
Badge +5

Hi Michael, 
Thanks for your reply! The best way to track the units per hour would be to send the calculated property to Amplitude. I tried playing around with the formulas chart in demo data, but the group by properties don’t work the same as your use-case. I hope you can get the idea though! 

Chart link: https://analytics.amplitude.com/demo/chart/new/6t1h3hs

So I’m taking the “duration” event property and turning it into hours. Then, I copied the same event and grouped by a different property. Divide it by # of hours and it should give units per hour with your data. 

Best, 
Loc

Reply