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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

countif column has entry (don't count blanks)

Hi,

 

I need to be able to count the number of entries in a data column and not count the blanks.

 

So for example under a column labelled "tag 1" there maybe 25,000 rows but only 150 entries with the other 24,850 rows left blank. I want the count to return 150.

 

Thanks,

10 REPLIES 10
g0bk1
Frequent Visitor

This is an old question, so you may try DISTINCTCOUNTNOBLANK(Table[column]) now

Sean
Community Champion
Community Champion

@Anonymous Try COUNTA( )

 

Here are the other counting functions...

https://msdn.microsoft.com/en-us/library/ee634956.aspx

 

Anonymous
Not applicable

Already tried COUNTA and it counts all the rows.

@Anonymous, @Sean is correct that if the data in those rows truly was empty that COUNTA should count them the way you describe and COUNTBLANK can be used to determine if they truly are blank.

 

In the event that there is something in them, like " " or something, the general format would be:

 

MyMeasure = CALCULATE(COUNT([NumericColumn]),FILTER(SomeTable[SomeColumn] <> ""))

The above formula is essentially the equivalent of COUNTA. The advantage here is that if it is truly not empty (blank) then you can adjust the "" in the formula to something like " ".

 

Hope you get to the bottom of it.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks but that formula is not working and potentially I'm doing it wrong

 

Airport Line = CALCULATE(count('EngagorData'[Tag-L3 » Airport Line]),FILTER('EngagorData','EngagorData'[Tag-L3 » Airport Line]<>""))

 

Above is the formula I used and it returns nothing.

 

In your formula you reference to "numericcolumn and sometable some column. am i missing something.

 

My data table is call "EngagorData" and the column is called "Tag-L3 » Airport Line". In each cell it is either blank or has the entry "Tag-L3 » Airport Line"

 

I have even tried this and returns nothing.

Airport Line = CALCULATE(count('EngagorData'[Tag-L3 » Airport Line]),FILTER('EngagorData','EngagorData'[Tag-L3 » Airport Line]="Tag-L3 » Airport Line"))

Sean
Community Champion
Community Champion

What numbers do you get from each of these

 

COUNTROWS( ), COUNTA( ), COUNT( ) and COUNTBLANK( )

 

and what DATA TYPE is the column?

Anonymous
Not applicable

Got it working

Measure = COUNTA('EngagorData'[Tag-L3 » Airport Line]) - COUNTBLANK('EngagorData'[Tag-L3 » Airport Line])

Sean
Community Champion
Community Champion

I must not be understanding this question???
ImkeF
Community Champion
Community Champion

I like to recommend that you use the query editor to clean your tables before loading them into the data model.

 

If a blank that isn't blank creates problems already at this stage, there's quite a likelihood that it will produce other errors as well later on - maybe some of them that will not as easily be spotted as this one.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Sean
Community Champion
Community Champion

Okay - so what does COUNTBLANK( )give you then? You are creating Measures right?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors