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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
baby_cabbage
Frequent Visitor

Help Replacing Blank Values with 0 in DAX!

baby_cabbage_0-1729183250828.png

I am calculating the retention rate of our customers.


In the Power BI matrix visual, the columns represent the Day Count, and the rows show the Registration date. To illustrate, I am analyzing the cohort that registered on September 21st. On day 0, 38 people from that cohort visited our shop. On day 1, 10 people visited, and on day 2, 2 people visited. However, from day 3 to day 15, no one from that cohort visited, so the cells display blank values.


In DAX, I want to replace these blank values with 0. I have tried using COALESCE(), ISEMPTY, NOT(ISBLANK), and adding +0, but none of these approaches are working. How can I modify the following measure to return 0 instead of blank?

Number of Customer Visits =
CALCULATE( COUNT(TableA[CustomerID]) )

Thank you very much!😭

1 ACCEPTED SOLUTION

Hello @baby_cabbage ,

 

Strange, have you checked if correct relationship is setup ?

Ok, lets try couple of more things :

 

1. Use COUNTROWS with Values : This approach will return 0 where no customers exist 

Number of Customers visited =
IF(
COUNTROWS(VALUES(TableA[CustomerID])) = 0,
0,
COUNT(TableA[CustomerID])
)

 

2. 

Number of Customers  visited=
SUMX(
VALUES(Day_Count), // replace with actual field name
IF(COUNT(TableA[CustomerID]) = BLANK(), 0, COUNT(TableA[CustomerID]))
)

 

Please let us know if this works.

 

Cheers

LinkedIn : https://www.linkedin.com/in/neeraj-kumar-62246b26/

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi @baby_cabbage ,

 

You can try formula like below:

vkongfanfmsft_1-1729495270284.png

 

Number of Customer Visits = 
IF (
    ISBLANK ( MAX(TableA[Customer Visits])),
    0,
    CALCULATE ( SUM( ( TableA[Customer Visits] ) )
))

vkongfanfmsft_2-1729495451633.png

 

Best Regards,
Adamk Kong

 

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

divyed
Super User
Super User

Hello @baby_cabbage ,

 

You can use IF condition to return desired value , something like :

 

NO_OF_CUST =
 VAR _CUst = CALCULATE(SUM(T_Registration[Cust_ID]))  // Replace with your measure, this is on dummy data
 RETURN
 IF (ISBLANK(_CUst)=TRUE(),0,_CUst)
 
You can replace your actual measure in if condition and should work

 

divyed_0-1729239290927.png

 

If this helps, please mark this as a solution. You can say special thank you by giving Kudos 🙂

 

Cheers.

LinkedIn : https://www.linkedin.com/in/neeraj-kumar-62246b26/

Thank you for dedication. Unfortunately it couldn't work on my report 

Hello @baby_cabbage ,

 

Strange, have you checked if correct relationship is setup ?

Ok, lets try couple of more things :

 

1. Use COUNTROWS with Values : This approach will return 0 where no customers exist 

Number of Customers visited =
IF(
COUNTROWS(VALUES(TableA[CustomerID])) = 0,
0,
COUNT(TableA[CustomerID])
)

 

2. 

Number of Customers  visited=
SUMX(
VALUES(Day_Count), // replace with actual field name
IF(COUNT(TableA[CustomerID]) = BLANK(), 0, COUNT(TableA[CustomerID]))
)

 

Please let us know if this works.

 

Cheers

LinkedIn : https://www.linkedin.com/in/neeraj-kumar-62246b26/
SachinNandanwar
Super User
Super User

Just a wild guess.try something like this

 

Customer Vists = CALCULATE(SWITCH(TRUE(),NOT ISBLANK(COUNT(TableA[CustomerID])),COUNT(TableA[CustomerID]),0))

 

 



Regards,
Sachin
Check out my Blog

:'( thank you for your help but it doesn't work

lbendlin
Super User
Super User

Number of Customer Visits =
COALESCE(CALCULATE( COUNT(TableA[CustomerID]) ),0)

Any other alternative to COALESCE(), ISEMPTY, NOT(ISBLANK), and adding +0? These didnt work

 

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.