Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

General Discussions

Discuss any topics that are not product-specific here.

map_values code

Kardasz
6 - Meteoroid

I received this code from someone who wrote it in Gazelle. I am trying to make it work in Alteryx. Can anyone help with that.

sum(reduce(map_values(map_filter(impressions_by_platform, (k, v) -> k like '%_only_tv')), 0, (s, x) -> s + x, s -> s)) total_tv_impressions

4 REPLIES 4
Qiu
21 - Polaris
21 - Polaris

This is really puzzle for me. 😁

Kardasz
6 - Meteoroid

The field impressions_by_platform contains the following as an example if this helps:

{"ctv":94,"dsk_only_tv":336,"mbl":1817,"ctv_only_ctv":94,"dsk_mbl":2153,"dsk":336,"mbl_only_mbl":1817}

dokuzsekiz
5 - Atom

Thank you

DataNath
17 - Castor
17 - Castor

Hey @Kardasz, I'm no expert in Gazelle but from running it in ChatGPT, it looks like the whole point of the expression here is just summing the values that belong to a name pair that is like '%_only_tv' i.e. ends in '_only_tv'. We can replicate this functionality in Alteryx by first parsing the value field with a JSON Parse tool, before then filtering to those that end in '_only_tv' - the EndsWith() function here. We then convert the value field to be numeric and can use a Summarize tool to sum this and leave the 'total_tv_impressions' field.

 

Gazelle.png

Labels
Top Solution Authors