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 using DAX

Hi

 

I am trying to count or tally up number of rows in a table but ignore any blank values.  The table is called in this example Projects and want to count the number of rows that have a date and ignore any null or blanks.  My matrix or pivot uses figures from a  table called AwardCounter.  So for example in Jan 2020 the measure brings up all the dates including any null values, so instead of a count = 13 I get count = 18. Is this because my relationship to each table, how the filters are flowing.  My filter context is coming from or is based on the AwardCounter, this populates the pivot or matrix Year and Monthname as simple stacked chart.     My measure or latest attempt looks like this - 

 

=CALCULATE(
                    COUNT('Projects'[Proj_No]),
                                  'Projects'[SbmitDate]<> BLANK()

                        )

 

Diagram View:

Diagram ViewDiagram View

Any help would be great, many thanks

Chris

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous ,

If you need blank
=CALCULATE(COUNTA('Projects'[Proj_No]) )
or
=CALCULATE(countrows('Projects'[Proj_No]) )


If you do need blank
=CALCULATE(COUNT('Projects'[Proj_No]),not(isblank('Projects'[SbmitDate])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

AntrikshSharma
Super User
Super User

try using KEEPFILTERS, since 'Projects'[SbmitDate] <> BLANK () expands internally to

= FILTER ( ALL ( 'Projects'[SbmitDate] ), 'Projects'[SbmitDate] <> BLANK () )

 at each month you get the same list of dates

=
CALCULATE (
    COUNT ( 'Projects'[Proj_No] ),
    KEEPFILTERS ( 'Projects'[SbmitDate] <> BLANK () )
)

 but using KEEPFILTERS you can avoid overriding the existing filters and KEEPFILTERS adds the new filter to the exiting filter

View solution in original post

4 REPLIES 4
AntrikshSharma
Super User
Super User

try using KEEPFILTERS, since 'Projects'[SbmitDate] <> BLANK () expands internally to

= FILTER ( ALL ( 'Projects'[SbmitDate] ), 'Projects'[SbmitDate] <> BLANK () )

 at each month you get the same list of dates

=
CALCULATE (
    COUNT ( 'Projects'[Proj_No] ),
    KEEPFILTERS ( 'Projects'[SbmitDate] <> BLANK () )
)

 but using KEEPFILTERS you can avoid overriding the existing filters and KEEPFILTERS adds the new filter to the exiting filter

Anonymous
Not applicable

Many thanks to all, very useful answers.

 

Chris

amitchandak
Super User
Super User

@Anonymous ,

If you need blank
=CALCULATE(COUNTA('Projects'[Proj_No]) )
or
=CALCULATE(countrows('Projects'[Proj_No]) )


If you do need blank
=CALCULATE(COUNT('Projects'[Proj_No]),not(isblank('Projects'[SbmitDate])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
lbendlin
Super User
Super User

You probably want to use COUNTA() or COUNTAX() instead.

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 community update carousel

Fabric Community Update - June 2025

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