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
julesdude
Post Partisan
Post Partisan

Cannot Convert the Value #date(2027, 3, 31) to type Text Error in Custom Column

Hi all,

 

I have a custom column with the following formula:

 

if Text.Length([Option Effective Date]) = null then Date.AddMonths([Option Start Date], [Notice Period]) else [Option Effective Date]

 

I am trying to apply logic that says that is the [Option Effective Date] column doesn't have a date in it (it either does or just reads 'null') then take the date from column [Option Start Date] and advance the months by the number in column [Notice Period].

 

Else just use the date in the [Option Effective Date] column.

 

Dates are pulled through when the condition is true. However I get error in cells with the above error message for the Else logic. 

What am I doing wrong?

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

In your case, Text.Length is not required. Hence, this would be enough.

= if [Option Effective Date] = null then Date.AddMonths([Option Start Date], [Notice Period]) else [Option Effective Date]

If you want to test for the presence of a date field

= if Value.Is(Date.From([Option Effective Date]), type date) then Date.AddMonths([Option Start Date], [Notice Period]) else [Option Effective Date]

View solution in original post

1 REPLY 1
Vijay_A_Verma
Super User
Super User

In your case, Text.Length is not required. Hence, this would be enough.

= if [Option Effective Date] = null then Date.AddMonths([Option Start Date], [Notice Period]) else [Option Effective Date]

If you want to test for the presence of a date field

= if Value.Is(Date.From([Option Effective Date]), type date) then Date.AddMonths([Option Start Date], [Notice Period]) else [Option Effective Date]

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.

Top Solution Authors