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!