Calculate Net Promoter Score in Vega Lite

I’m trying to calculate and then visualize Net Promoter Score (NPS) from a table of evaluation scores submitted through a form.

NPS = (% promoters - % detractors) / total number respondents

Where:
promoter values = 9-10
detractor values = 1-6
total respondents = 1-10

I’m new to Vega and got stuck pretty quickly. I’m pretty sure I need to do a calculate transform step, but not sure how to assign e.g. “promoter” to values of 9 and 10. Is binning the approach, or is there some conditional logic that could work?

I’m interested in ways to do this without Vega as well, but I like not having to add extra fields to my table if it is possible to do the calculation within the app module.

Thanks in advance for any assistance!

Decided to add an extra field in Airtable that uses conditional logic to assign “promoter”, “detractor” and “passive” values when appropriate number in the “NPS” field.

Now just need to figure which are the appropriate transforms in Vega-lite (I think)

I can probably help a little with this, but I’m totally slammed for the week.

Thanks for the response, Bill! I’m going to continue to tinker with it when I get the time. Will post any updates to the thread.

Figured it out. The key was to transform values [promoter, passive, detractor] into a score [+1, 0, -1] and use “joinaggregate” to create a sum_score that effectively equals the “promoters - detractors” bit of original equation. Rest was easy. Now to make it look pretty!

1 Like

This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.