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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
StoryofData
Helper III
Helper III

Empty Date Value

Wondering if there a smart way to do this, I have table with cases and their open and closed dates. 

For the times when the case is still open, I want the card to show "Still Open", I have achieved this using two measures: 

 

Date Closed = CALCULATE(MAX('Query1'[DateClosed]))
Date Closed Blank = IF( ISBLANK([Date Closed]) , "Still Open", [Date Closed] )
 
Is there a smarter way to achieve this, without using two measures?

 

StoryofData_0-1686237113347.png

 

1 ACCEPTED SOLUTION

sure 🙂

 

Date Closed Blank = COALESCE(FORMAT(CALCULATE(MAX('Query1'[DateClosed])),"MM/DD/YYYY") , "Still Open")

View solution in original post

7 REPLIES 7
lbendlin
Super User
Super User

Your approach will only work when [Date Closed] is of type text. 

 

You can use COALESCE

 

Date Closed = FORMAT(CALCULATE(MAX('Query1'[DateClosed])),"MM/DD/YYYY")
Date Closed Blank = COALESCE([Date Closed] , "Still Open")

Thank you! So there is no way to have only one measure to achieve this?

sure 🙂

 

Date Closed Blank = COALESCE(FORMAT(CALCULATE(MAX('Query1'[DateClosed])),"MM/DD/YYYY") , "Still Open")

For some reason, it produces a blank instead of "Still Open", meaning the card does not show anything at all. Could there be an issue?

=COALESCE
(FORMAT(CALCULATE(MAX('Query1'[DateClosed])),"MM/DD/YYYY"),"Still Open")

Ah, right, I remember. There is a bug in FORMAT that happily returns an empty string instead of BLANK().

 

Oh well, back to your version.

 

=IF(ISBLANK(MAX('Query1'[DateClosed])),"Still Open",FORMAT(MAX('Query1'[DateClosed]),"MM/DD/YYYY"))

 

Thank you! Works now!

And, interesting, I guess that bug can be used to our advantage in some cases

Thank you!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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