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 September 15. Request your voucher.

Reply
Anonymous
Not applicable

How to return 0% if blank in KPI visual

Hello everyone,

 

As a beginner at PowerBI, I would appreciate any help.

 

I am using the KPI visual to display a percentage. The issue is that when I use a filter on my dashboard to look at the KPIs for a specific segment, if a KPI only contains "null", it returns 100% (instead of 0%). I believe this is because it is counting all of the cells as a value when they are all null. The KPI visual works just fine if there is at least one non-null value and displays the correct percentage.

 

The column from which I'm pulling the data either has "1" or "null", and I want to calculate the count (or sum) of the "1" values over all of the column values. Below are the specific displays I would want to see (values/column total %).

 

Example 1: Display 40%

Column
1
null
null
1
null

 

Example 2: Display 0%

Column
null
null
null
null
null

 

Keep in mind that in terms of visual, I only want to see the percentage as follow (not in a table):

KarineT_1-1669059907827.png

 

Basically, would anyone know how I can display a percentage as 0% when all values are null?

 

Thank you!

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

Based on your description, I wonder the null value in your sample is text "null" or blank null.

In Power BI Desktop data view, please check if the blank cells display blank like below:

vkalyjmsft_0-1669106817414.png

If not, if there is "null" text display, it prove they are actually not blank, then you should replace "null" will blank in Power Query.

I create a common sample and the code works fine.

Measure1 =
DIVIDE ( COUNTA ( 'Table'[Column1] ), COUNTROWS ( 'Table' ) )
Measure2 =
DIVIDE ( COUNTA ( 'Table'[Column2] ) + 0, COUNTROWS ( 'Table' ) )

Result:

vkalyjmsft_1-1669107078365.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

Based on your description, I wonder the null value in your sample is text "null" or blank null.

In Power BI Desktop data view, please check if the blank cells display blank like below:

vkalyjmsft_0-1669106817414.png

If not, if there is "null" text display, it prove they are actually not blank, then you should replace "null" will blank in Power Query.

I create a common sample and the code works fine.

Measure1 =
DIVIDE ( COUNTA ( 'Table'[Column1] ), COUNTROWS ( 'Table' ) )
Measure2 =
DIVIDE ( COUNTA ( 'Table'[Column2] ) + 0, COUNTROWS ( 'Table' ) )

Result:

vkalyjmsft_1-1669107078365.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hello,

So I tried the exact same code with a different column, but I'm now getting this error message: 

KarineT_0-1669223058817.png

 

Any clue as to why? I tried changing the value type to numbers, but it didn't work... Thanks!

aj1973
Community Champion
Community Champion

@Anonymous 

Maybe add 0 or BLANK()

DIVIDE ( COUNTA ( 'Table'[Column2] ) + 0, COUNTROWS ( 'Table' ), 0 )

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Anonymous
Not applicable

Hi Kalyj,

 

Thank you so much! The code worked 🙂

aj1973
Community Champion
Community Champion

Hi @Anonymous 

To your measure add " + 0 "

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Anonymous
Not applicable

Hi Armine,

 

I tried adding a 0 in the measure, but it doesn't seem to work. 

 

My measure looks like this:

 

Count = COUNTA (table[column])+0

aj1973
Community Champion
Community Champion

Please try this

Count = IF(ISBLANK(COUNTA (table[column])), 0, COUNTA (table[column])

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

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.