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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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