Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

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 ...
  • wdx223_Daniel's avatar
    3 years ago
    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
               )