Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi everyone!
I´m looking for a DAX that allows me to count the total number of a specific text value in a column, but if it is none/blank I want to show 0 instead of blank.
I was trying to use this DAX formula:
Count of Red colour= COUNTROWS(FILTER(TABLE, TABLE[Colour]="Red")) +0
But for some reason when I add this measure as a value in a table it doesn´t load (my table already has a lot of values, not sure if that is related to that issue) when I remove the +0 it loads alright in the table, but I would like to show the 0 if there blank.
Is there another DAX that is better to do this? thanks!
Solved! Go to Solution.
Please try
Count of Red colour =
IF (
NOT ISBLANK ( COUNTROWS ( TABLE ) ),
IF (
ISBLANK ( COUNTROWS ( FILTER ( TABLE, TABLE[Colour] = "Red" ) ) ),
0,
COUNTROWS ( FILTER ( TABLE, TABLE[Colour] = "Red" ) )
)
)
Hi @tamerj1 and @Anonymous both Dax work in terms of getting 0 instead of blank on my table visual, the only problem is that I get multiple rows instead of concentrated in one row, I`m using a column ID that generates the rows, but with this formula, I'm getting multiple times the same ID for 0, is there any DAX that can cover that issue as well all together?.
For the creation of my table, I'm using columns that belong to 2 different tables but they share in common the ID column.
Please try
Count of Red colour =
IF (
NOT ISBLANK ( COUNTROWS ( TABLE ) ),
IF (
ISBLANK ( COUNTROWS ( FILTER ( TABLE, TABLE[Colour] = "Red" ) ) ),
0,
COUNTROWS ( FILTER ( TABLE, TABLE[Colour] = "Red" ) )
)
)
Thanks a lot! works perfect now!
Hi @maneschr2022 ,
this seems a very apt use case for the COALESCE() function. You can use it like :
Count of Red colour NOBLANK =
COALESCE(COUNTROWS(FILTER(TABLE, TABLE[Colour]="Red")),0)
Regards
This approach of using Coalesce() is much cleaner and easier to maintain as calculation is not repeated.
use
Count of Red colour= IF ( ISBLANK (COUNTROWS(FILTER(TABLE, TABLE[Colour]="Red"))), 0, COUNTROWS(FILTER(TABLE, TABLE[Colour]="Red")))
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
20 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
26 | |
10 | |
10 | |
9 | |
6 |