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
Brett007
Helper III
Helper III

Layered If Statement with a mix of Dates and Text

I made a custom column similar to this;


Text or Date = 
If(ISBLANK(Table1[Status], Table1[Step Status],
If(Table1[Status] = "In Progress", Table1[Step Due Date].[Date],

If(Table1[Status] = "C=Complete", Table1[Step Actual Date].[Date],

If(Table1[Status] = "Not Required", "Not Required",
Blank())))))

I receive a error:

Expressions that yield variant data-type cannot be used to define calculated columns. 

 

I have the column set to text.  I tried MIN( around the dates as well. 

 

Any ideas of what to try next?

Thanks

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

First, you need to close your ISBLANK parentheses.

 

Addressing your actual question, you can use the FORMAT function to convert date to whatever format you'd like. For example, FORMAT ( Table1[DueDate], "mm/dd/yy" ) or FORMAT ( Table1[DueDate], "yyyy-mm-dd" ).

 

This is a good case to use a SWITCH function too.

Text or Date =
SWITCH (
    Table1[Status],
    BLANK (), Table1[Step Status],
    "In Progress", FORMAT ( Table1[Step Due Date], "yyyy-mm-dd" ),
    "C=Complete", FORMAT ( Table1[Step Actual Date], "yyyy-mm-dd" ),
    "Not Required", "Not Required",
    BLANK ()
)

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @Brett007 

Please try something like below.

 

Text or Date = 
If(ISBLANK(Table1[Status], Table1[Step Status],
If(Table1[Status] = "In Progress", format(Table1[Step Due Date].[Date], "ddmmmmyyyy"),

If(Table1[Status] = "C=Complete", format(Table1[Step Actual Date].[Date], "ddmmmmyyyy"),

If(Table1[Status] = "Not Required", "Not Required",
Blank())))))

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

AlexisOlson
Super User
Super User

First, you need to close your ISBLANK parentheses.

 

Addressing your actual question, you can use the FORMAT function to convert date to whatever format you'd like. For example, FORMAT ( Table1[DueDate], "mm/dd/yy" ) or FORMAT ( Table1[DueDate], "yyyy-mm-dd" ).

 

This is a good case to use a SWITCH function too.

Text or Date =
SWITCH (
    Table1[Status],
    BLANK (), Table1[Step Status],
    "In Progress", FORMAT ( Table1[Step Due Date], "yyyy-mm-dd" ),
    "C=Complete", FORMAT ( Table1[Step Actual Date], "yyyy-mm-dd" ),
    "Not Required", "Not Required",
    BLANK ()
)

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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