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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Countrows returns null instead of 0

I have a data like this 

 

Column 1Column 2
null6
null3
nullnull

 

I am counting the occurrences of values greater than 9 in both columns but both columns returns null while in reality the column 1 should return null while the column two should return 0. 

 

var column1 = COUNTROWS ( FILTER ( 'nps', 'nps'[Column 1] IN { 7, 8, 9, 10 } ) )

var column2 = COUNTROWS ( FILTER ( 'nps', 'nps'[Column 2] IN { 7, 8, 9, 10 } ) )

 

I am doing some other calculation at the end as well

7 REPLIES 7
Anonymous
Not applicable

Is there any way we can ignore the null values in the columns from calculations so that with the rows that have a data with values but returns a null I can force zero it?

tamerj1
Super User
Super User

@Anonymous 
COUNTROWS of an empty table is BLANK not 0

To force zero use

var column2 = COUNTROWS ( FILTER ( 'nps', 'nps'[Column 2] IN { 7, 8, 9, 10 } ) ) + 0

Genius!
Anonymous
Not applicable

Won't that automatically use 0 where the column or cell value is actually null and should remain the same? 

@Anonymous 
FILTER ( 'nps', 'nps'[Column 2] IN { 7, 8, 9, 10 } ) returns an empty table. Any aggregation of an empty table in DAX returns a blank not 0

Anonymous
Not applicable

Is there any way we can ignore the null values in the columns from calculations so that with the rows that have a data with values but returns a null I can force zero it?

@Anonymous 
I aleady answered that in my first reply, just + 0

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.