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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
nayan28apr
Helper I
Helper I

how to replace blank with zero in a metrix

Hi,

 

I have to replace blank with zero in metrix visual in power bi.

I am showing sales of 3 dimension region, cluster, country as drill down rows against period, month and day wise on the column.

This is the basic formula

Sales for P05 =
CALCULATE(
SUM(fact_global_daily_sales[actual_sales]),
FILTER('Calendar','Calendar'[year_number]=2021),
FILTER('Calendar','Calendar'[period title]="P05")
)

showing results of the table.

 

nayan28apr_0-1623402128018.png

 

When i write
Var MonthlySales

CALCULATE(
SUM(fact_global_daily_sales[actual_sales]),
FILTER('Calendar','Calendar'[year_number]=2021),
FILTER('Calendar','Calendar'[period title]="P05")
)
Return
IF(MonthlySales=BLANK(),0,MonthlySales)

or 

IF(NOT(ISBLANK(MonthlySales)),MonthlySales,0)


All table starts showing zero values from above 2 return statements.

nayan28apr_1-1623402508734.png

 

The records for which it's showing zero for them there are no rows in the data tables.
How can i first check for such rows and mark them zero before the actual formulas start.

Thanks

 

 

11 REPLIES 11
ryan_mayu
Super User
Super User

@nayan28apr 

have you tried this

Sales for P05 =
CALCULATE(
SUM(fact_global_daily_sales[actual_sales]),
FILTER('Calendar','Calendar'[year_number]=2021),
FILTER('Calendar','Calendar'[period title]="P05")
) +0




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks for the reply.
I have tried as below, but it doesn't work and showing zeros.

This is strange to see it start showing P1, P2 in the column when we add +0

nayan28apr_0-1623403961346.png

 

@nayan28apr 

in your original DAX, you set period title is 05, is that May? Your screenshot shows the result of Jan.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




What I want is :

1. This matrix should show latest period information as we proceed further. Like P6 started now and so on.

2. This formula works fine for me but it shows blank. This is basically that combination rows are not present in the data for that day. I want to show 0 when no values.

nayan28apr_0-1623655772103.png

3. As soon as i apply condition or look to catch this scnarios. All values coming as 0 and metrix started showing values from P1 to P6.

@nayan28apr 

have you tried to modify the last part of DAX

iF(not(isblank(monthlysales)),monthlysales,0)





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks for the reply.
Yes, i tried this initially but not worked as well.

IF(NOT(ISBLANK(MonthlySales)),MonthlySales,0)

As soon as I pass zero, all becomes zero.

@nayan28apr 

can you share the pbix file after removing sensitive data?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi, Thanks for your reply.
Attached sample pbix on the below location:

https://drive.google.com/file/d/1SJPSZConmHt-soh9QoVg98VsSz7cPHxJ/view?usp=sharing

Thanks

Thanks for your reply.

We have P5 starts from May 6th to June5th so it may include May and June also, its not calendar months. Now I add +0 the matrix starts showing from P1 and period title = P5 condition fails.

I have also tried with count of rows in if condition as below,
it identified blank records and only give zero for it. But don't show actual records which has values in it. Issue the same it shows P1 to P3 though we have given P5.

nayan28apr_0-1623404267859.png

 

@nayan28apr 

the fasteset way is to add a visual filter and select P05

1.PNG

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.