Question

Average Number of Unique Items in an Array

  • 5 April 2024
  • 1 reply
  • 28 views

Userlevel 2
Badge

I have a parameter that is an array of ID’s. I would like to understand the average size of this array between my events. 

 

I saw this Distinct Property Values Per User option in the Segmentation chart. 

 

This seems promising but I just want to understand if I’m reading the results correctly. I could see it one of two interpretations:

  1. Each array SET is a “value”. Therefore if I fire this event 3 times with 3 different array contents, then that would be 3 different values
  2. Each value within the array is counted as a distinct value, and so if there are 6 items in the array, then a user would appear as “6” for that day. 

I would hope it is #2, as it would help me solve my questions. But a clarification of how this works would be great. 


1 reply

Userlevel 3
Badge +5
Hi Justin,

Thank you for writing in. Happy to help!

You're on the right track! The 'Distinct Property Values Per User' option in the Event Segmentation chart counts each unique value within the array as a distinct value.

For example, if a user performs the following events:

Event A where array = [1,2,3]
Event A where array = [4,5,6]
Event A where array = [5,6]

'Distinct Property Values Per User' would be 6 items.

Furthermore, you can create a derived property to count the number of items in an array using the ITEM_COUNT (property) function. Here is more information about derived properties: https://help.amplitude.com/hc/en-us/articles/5874857623707-Derived-properties

Hope this helps, and please let me know if you have any questions.

Best regards,
Thao


P.S. Checkout upcoming events and user meetups on our events page.

Reply