0

JSON Selection Path (Amplitude Event Segmentation)

Hi, 

I'm attempting to connect an Amplitude REST datasource and am having trouble getting the path right for retrieving values from the following JSON response. 

I've experimented with kf:element_at which can successfully select a single element, but I can't seem to select all the elements in the array. Any ideas?

 

Thanks!

6 comments

  • 0
    Avatar
    Josh Cohen-Collier

    Hi Charles,

    Thanks for posting in our Community!

    This is a bit of a tricky data structure, that requires a surprisingly complicated answer.
    What we actually need to know right away is how many items there will be in the series. as we need to pass it in as a limit.
    In this case, I used the number 5.

    This actually requires the use of the DATASOURCE and MAP functions.
    We need to do the following logic;
    -Go through each of the numbers 1-5 one at a time, and assign them to a variable $item
    -Get the kf:element_at of that item, by passing in the item ID via the DATASOURCE function

    Hope this helps!



    Best regards,
    Joshua
    _________________
    Joshua Cohen-Collier,
    Technical Support Specialist, Klipfolio

  • 0
    Avatar
    Charles Teague

    I would've never guessed, and this work great- thank you!

     

     

  • 0
    Avatar
    Josh Cohen-Collier

    Charles,

    No problem!

    Happy to help.

    Warm regards,
    Joshua

  • 0
    Avatar
    Toby Butterworth

    Joshua, where does one get this datasource ID from please?

  • 0
    Avatar
    Josh Cohen-Collier

    Hi Toby,

    Great question!
    You can find in the 'view' page from the Library.
    Here are some more specific instructions from our help center.

    Best regards,
    Joshua

  • 1
    Avatar
    Jason Gong

    Maybe experiment with the chart type to get it to return the data in another format because I've found that to be possible. When it's in this format you can just do data/series[1]/value to grab the series. For me this was just an event segmentation chart.

Please sign in to leave a comment.