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 August 31st. Request your voucher.

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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