Skip to content

nps

nps(rating)

Description

Returns the NPS (Net Promoter Score) of rating (which represents customer satisfaction between 0 and 10):

NPS = "% promoters" - "% detractors"

where:

  • "% promoters" = 100 * countif(rating >= 9) / count(*)
  • "% detractors" = 100 * countif(rating <= 6) / count(*)

Usage

Call or Deploy nps ?
Call nps directly

The easiest way to use bigfunctions

  • nps function is deployed in 39 public datasets for all of the 39 BigQuery regions.
  • It can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
  • (You need to use the dataset in the same region as your datasets otherwise you may have a function not found error)

Public BigFunctions Datasets

Region Dataset
eu bigfunctions.eu
us bigfunctions.us
europe-west1 bigfunctions.europe_west1
asia-east1 bigfunctions.asia_east1
... ...
Deploy nps in your project

Why deploy?

  • You may prefer to deploy nps in your own project to build and manage your own catalog of functions.
  • This is particularly useful if you want to create private functions (for example calling your internal APIs).
  • Get started by reading the framework page

Deployment

nps function can be deployed with:

pip install bigfunctions
bigfun get nps
bigfun deploy nps

Examples

NPS = 25 <-- 50 % (promoters) - 25 % (detractors)

with sample_data as (

  select 9 as rating
      union all
      select 10 as rating
      union all
      select 6 as rating
      union all
      select 8 as rating

)


select bigfunctions.eu.nps(rating)
from sample_data
with sample_data as (

  select 9 as rating
      union all
      select 10 as rating
      union all
      select 6 as rating
      union all
      select 8 as rating

)


select bigfunctions.us.nps(rating)
from sample_data
with sample_data as (

  select 9 as rating
      union all
      select 10 as rating
      union all
      select 6 as rating
      union all
      select 8 as rating

)


select bigfunctions.europe_west1.nps(rating)
from sample_data
+-----+
| nps |
+-----+
| 25  |
+-----+


Need help or Found a bug?
Get help using nps

The community can help! Engage the conversation on Slack

We also provide professional suppport.

Report a bug about nps

If the function does not work as expected, please

  • report a bug so that it can be improved.
  • or open the discussion with the community on Slack.

We also provide professional suppport.


Show your ❤ by adding a ⭐ on