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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register 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

Anonymous
Not applicable

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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