Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
aqsa31
Helper II
Helper II

Exclude null values while calculating NPS score

Hi, I am using this dax code to calculate the NPS 

 

NPS Score demo =

//be sure you have a question in your survey asking "How likely would you be to recommend us?" with a scale of 0-10
VAR detractors = CALCULATE(
           COUNTROWS('nps'),
                     FILTER('nps',
                     'nps'[NPS]<=6)
           )

//don't forget to make your NPS question column into a whole number data type
VAR passives = CALCULATE(
           COUNTROWS('nps'),
                     FILTER('nps',
                     'nps'[NPS]=7)
           )
           +CALCULATE(
                     COUNTROWS('nps'),
                      FILTER('nps',
                     'nps'[NPS]=8)
           )

VAR promoters = CALCULATE(
           COUNTROWS('nps'),
                     FILTER('nps',
                     'nps'[NPS]>=9)
           )

VAR total = COUNTROWS('nps')

VAR score = (promoters/total*100)-(detractors/total*100)
RETURN If(
                     ISBLANK(score),
                     0,
                     score
           )
It works perfectly fine, but the issue is I have null values in the column I am using to calculate the NPS. This is what my data looks like 
 
ClientNPSSessionAttendees
Client 17Skills tomorrow34
Client 14Skills tomorrow23
Client 16CV writing645
Client 19CV writing67
Client 210Digital Marketing 
Client 210Digital Marketing 
Client 27Audience developemnt 
Client 210Audience developemnt 
Client 39Marketing techniques 
Client 33Marketing techniques 
Client 32Marketing techniques 
Client 3 Marketing techniques45
Client 3 Marketing techniques34
1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

NPS Score demo =

 

//be sure you have a question in your survey asking "How likely would you be to recommend us?" with a scale of 0-10
VAR _tbl= FILTER('nps',NOT(ISBLANK('nps'[NPS])))
VAR detractors = COUNTROWS(FILTER(_tbl,'nps'[NPS]<=6))

 

//don't forget to make your NPS question column into a whole number data type
VAR passives =COUNTROWS(FILTER(_tbl,'nps'[NPS]=7||'nps'[NPS]=8))
         
VAR promoters =COUNTROWS(FILTER(_tbl,'nps'[NPS]>=9))

 

VAR total = COUNTROWS(_tbl)

 

VAR score = (promoters/total*100)-(detractors/total*100)
RETURN If(
                     ISBLANK(score),
                     0,
                     score
           )

View solution in original post

1 REPLY 1
wdx223_Daniel
Super User
Super User

NPS Score demo =

 

//be sure you have a question in your survey asking "How likely would you be to recommend us?" with a scale of 0-10
VAR _tbl= FILTER('nps',NOT(ISBLANK('nps'[NPS])))
VAR detractors = COUNTROWS(FILTER(_tbl,'nps'[NPS]<=6))

 

//don't forget to make your NPS question column into a whole number data type
VAR passives =COUNTROWS(FILTER(_tbl,'nps'[NPS]=7||'nps'[NPS]=8))
         
VAR promoters =COUNTROWS(FILTER(_tbl,'nps'[NPS]>=9))

 

VAR total = COUNTROWS(_tbl)

 

VAR score = (promoters/total*100)-(detractors/total*100)
RETURN If(
                     ISBLANK(score),
                     0,
                     score
           )

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors