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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
common763
Helper III
Helper III

Date Calculation is blank if one of the dates blank

I am getting a "Expressions that yeild variant data-type cannot be used to define calculated columns" error" if I change the 0 to "".  I know this is simple but need help.  I have the below calculated column.  

 

Days btw dates = if(ISBLANK(DATE1,0, if(ISBLANK(DATE2),0,NETWORKDAYS(DATE1,DATE2)))
 
Right now it is displaying 0 if the DATE1 or DATE2 is blank.  I want it to display "" or nothing if one or both of the dates are missing.  Can someone help me tweak this calculated column to do so if one of the dates or both are blank?  
1 ACCEPTED SOLUTION
Dangar332
Super User
Super User

Hi, @common763 


Try below measure

 

 Days btw dates=
if(
ISBLANK(DATE1),
0,
if(
ISBLANK(DATE2),
0,
NETWORKDAYS(DATE1,DATE2)))


OR 

Days btw dates =
 if(
   ISBLANK(DATE1),
   "",
   if(
     ISBLANK(DATE2),
     "",
     convert( NETWORKDAYS(DATE1,DATE2),STRING)
   )
 )

 

View solution in original post

3 REPLIES 3
common763
Helper III
Helper III

My head wasnt working yesterday...all i had to do was this below...I was putting "" instead of Blank()

 

Days btw dates = if(ISBLANK(DATE1,0if(ISBLANK(DATE2),0,NETWORKDAYS(DATE1,DATE2)))

to

Days btw dates = if(ISBLANK(DATE1,BLANK(), if(ISBLANK(DATE2),BLANK(),NETWORKDAYS(DATE1,DATE2)))

common763
Helper III
Helper III

thanks.  this works.  Appreciate it. 

Dangar332
Super User
Super User

Hi, @common763 


Try below measure

 

 Days btw dates=
if(
ISBLANK(DATE1),
0,
if(
ISBLANK(DATE2),
0,
NETWORKDAYS(DATE1,DATE2)))


OR 

Days btw dates =
 if(
   ISBLANK(DATE1),
   "",
   if(
     ISBLANK(DATE2),
     "",
     convert( NETWORKDAYS(DATE1,DATE2),STRING)
   )
 )

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.