# Calculate Net Promoter Score in Vega Lite

Topic Labels: Extensions
Solved
2502 4
cancel
Showing results for
Did you mean:
5 - Automation Enthusiast

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!

1 Solution

Accepted Solutions
5 - Automation Enthusiast

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!

4 Replies 4
5 - Automation Enthusiast

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)

17 - Neptune

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

5 - Automation Enthusiast

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.

5 - Automation Enthusiast

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!