Solved

How to use event property as a parameter in user formula?

  • 26 July 2022
  • 3 replies
  • 33 views

I want to show performance of some computations inside my app. Duration of the computations depends on input size, so I want to compute avg(COMPUTATION_DURATION / INPUT_SIZE), but both values are params of the same event.

icon

Best answer by Yuanyuan Zhang 27 July 2022, 11:04

View original

3 replies

Of course I could just send that information in the event, but I don’t want to increase event size to avoid unnecessary network usage + I want to compute that for legacy data also

Userlevel 7
Badge +10

Hey @pkolesnikov 

I don’t think there is an easy/direct way of isolating individual property values and doing such arithmetic inside the custom formula view. However, it supports arithmetic on values returned on property aggregation eg. PROPSUM,etc. So something like SUM ( all COMPUTATION_DURATION values ) / SUM( all INPUT_SIZE values ) recorded in a day/week/month is possible

I believe you want to calculate this ratio for every event and then average it over the time interval ? If yes, then the derived properties feature could help you do this i.e. create a new property on the relevant event which calculates this COMPUTATION_DURATION / INPUT_SIZE ratio. And then use the measured as Average of Property Value metric in the event seg chart or even the PROPAVG(A) custom formula.

Note that Derived properties is only available to enterprise customers and customers who have purchased the Govern add-on.

Let me know if I have interpreted your use case correctly. Hope this helps.

 

Userlevel 3
Badge +5

Hi @pkolesnikov

Besides Saish’s amazing suggestions, if your intention is indeed to make calculation of the properties that belong to one event and make it a new property, our Computations feature is perfect for it. Please note that this feature is only included in our Recommend Package.

In case you just want to see one average value during each day/week/month interval, instead of getting the ratio for each event, you could use a custom formula like this: https://analytics.amplitude.com/demo/chart/new/7dpczn0

Hope this helps!

Reply