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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Sid10
Helper I
Helper I

Custom measure that assigns a null as 0 else 1

I want to create a measure that counts a column if it has a non-null value and not count it when null.
To do that I am using the function of SUMX and IF(ISBLANK(Column),0,1). However this still treats the null values as 1. Is that expected behavior? What is an alternative to this function to accomplish what I want? Thank you for your help. 
1 ACCEPTED SOLUTION

Thank you for that note. You were actually right - the function used was indeed correct - it was an oversight on my part. I will mark your response as a solution. 
This is the formula I use for Table (tbl1) which has various columns (Col1, Col2...):
Sum_of_Columns = SUMX(tbl1,IF(ISBLANK(tbl1[Col1]),0,1)+IF(ISBLANK(tbl1[Col2]),0,1)+...

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

This measure should work

Measure = calculate(countrows(Data),Data[Column]<>blank())

If it does not work, then share some data to work with and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Idrissshatila
Super User
Super User

Hello @Sid10 ,

 

the measure you mentioned should work, can you show us how you're using it?



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Thank you for that note. You were actually right - the function used was indeed correct - it was an oversight on my part. I will mark your response as a solution. 
This is the formula I use for Table (tbl1) which has various columns (Col1, Col2...):
Sum_of_Columns = SUMX(tbl1,IF(ISBLANK(tbl1[Col1]),0,1)+IF(ISBLANK(tbl1[Col2]),0,1)+...
arava
Regular Visitor

Check in Power Query to ensure that the values are in fact "null" and not an empty string or invisible unicode character. If that does not fix your issue, I would employ the LEN( ) function (IE a length of 0 is blank).  

Hi - I do see that the values are "null" in query editor. And the data type is number and not a text string. So, not sure if LEN () will work or will it? Any other alternative?

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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