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
jamesclark458
Frequent Visitor

Exclude NULL values from VAR Measures

Hi folks,

 

I have a series of visuals that calculate a Net Promoter Score style output. 

 

I was given elsewhere in this forum the below measure, you will note that at the bottom that NULL values are assigned a score of 0. 

 

This is skewing the results, and I am wondering how I exclude NULL values from the calculation?

 

Any help would be greatly appreciated,


Thanks


Jamie 

 

NPS Score =
//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('Repository'),
                     FILTER('Repository',
                     'Repository'[NPS]<=6)
           )

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

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

VAR total = COUNTROWS('Repository')

VAR score = (promoters/total*100)-(detractors/total*100)

RETURN If(
                     ISBLANK(score),
                     0,
                     score
           )
1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @jamesclark458 ,

Please try to filter the table that you want to exclude null value, then use this new table to calculate, like below dax formula, please refer:

var tmp= filter(All("Table Name"),[ColumnName]<>"null")

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
jamesclark458
Frequent Visitor

Hi @v-binbinyu-msft 

 

Thank you for your help with this - apologies it has taken so long for me to respond. 

This is in action now,

 

Jamie

v-binbinyu-msft
Community Support
Community Support

Hi @jamesclark458 ,

Please try to filter the table that you want to exclude null value, then use this new table to calculate, like below dax formula, please refer:

var tmp= filter(All("Table Name"),[ColumnName]<>"null")

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.