Skip to main content

Power BI

Declined

Count should return 0 instead of (Blank)

Vote (575) Share
Stephane Viot's profile image

Stephane Viot on 07 Oct 2015 23:52:58

Count of should return 0 instead of '(Blank)' (looks better on a Dashboard)

Administrator

You can do this with the COALESCE function: https://docs.microsoft.com/en-us/dax/coalesce-function-dax. For example:

= COALESCE(SUM(FactInternetSales[SalesAmount]), 0)
Comments (54)
Stephane Viot's profile image Profile Picture

Eric McGowan on 05 Jul 2020 23:06:08

RE: Count should return 0 instead of (Blank)

Creating a measure for every card is too excessive and limits functionality......

Stephane Viot's profile image Profile Picture

Tom Good on 05 Jul 2020 23:04:27

RE: Count should return 0 instead of (Blank)

Adding zero to the measure does not work well since it breaks formatting on other visuals such as charts.

Stephane Viot's profile image Profile Picture

Kieran Wood on 05 Jul 2020 23:00:13

RE: Count should return 0 instead of (Blank)

Also note ... The best way of handling nulls is by using a find replace in Power Query.
Where ever possible data transformations should be performed in Power Query.

Stephane Viot's profile image Profile Picture

Kieran Wood on 05 Jul 2020 23:00:13

RE: Count should return 0 instead of (Blank)

Important as alternative would be to use IsBlank which would mean performing the COUNT twice.

Stephane Viot's profile image Profile Picture

Patricia on 05 Jul 2020 22:42:16

RE: Count should return 0 instead of (Blank)

Adding a 0 is fine, but it's not always a solution. Not in all cases. I agree with David Cadman, an option to choose how to display (Blank). Sometimes 0 is alright, something plain text saying "None". Anything but (Blank).

Stephane Viot's profile image Profile Picture

Hasan on 05 Jul 2020 22:40:31

RE: Count should return 0 instead of (Blank)

Adding + 0 to your formula should take care of the blank

Stephane Viot's profile image Profile Picture

David Cadman on 05 Jul 2020 22:40:29

RE: Count should return 0 instead of (Blank)

It makes sense that Blank is returned by formulas sometimes, but on say the Card visual it would make sense to have the option "Display (Blank) as 0" Y/N

Stephane Viot's profile image Profile Picture

Tom Laresch on 05 Jul 2020 22:39:17

RE: Count should return 0 instead of (Blank)

DAX returning blank makes sense because of what it means in the context of charts. If there is no data for a particular dimension, then generally we do not want it to draw a line or a bar. However, in the case of cards, I believe the default behavior would be best if it showed zero instead of (Blank). Given that (Blank) is the established behavior, I would ask that a formatting option be created for card and multi-card to show 0 instead of blank.

Stephane Viot's profile image Profile Picture

Power BI User on 05 Jul 2020 22:38:49

RE: Count should return 0 instead of (Blank)

Adding a zero on the measure worked, great workaround.

Stephane Viot's profile image Profile Picture

Vishal on 05 Jul 2020 22:37:37

RE: Count should return 0 instead of (Blank)

Quick work around if anyone is interested. Adding a zero forces Power BI to display Zero!

CALCULATE(COUNTROWS(table),table[column]) + 0