map_values code
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Labels:
- Community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
This is really puzzle for me. 😁
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
