cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
SK_JOB
Regular Visitor

Cannot convert value '' of type text to type Date

 

Hello,

I am getting this error : Cannot convert value '' of type text to type Date. for this formula:

 

 

_Rev. Rec. Term in Days =
DATEDIFF ( [_Rev. Rec. Start Date], [_Rev. Rec. End Date], DAY )

 

 

 

Where:

 

 

_Rev. Rec. Start Date =
FORMAT (
    DATEVALUE ( MIN ( 'Transaction Lines'[Rev. Rec. Start Date] ) ),
    "mm/dd/yyyy"
)

 

 

 

and

 

 

_Rev. Rec. End Date =
FORMAT (
    DATEVALUE ( MIN ( 'Transaction Lines'[Rev. Rec. End Date] ) ),
    "mm/dd/yyyy"
)

 

 

Rev. Rec. Start Date and Rev. Rec. End Date are of Date Datatype.


I tried this:

 

_Rev. Rec. Term in Days =
IF (
    ISBLANK ( DATEDIFF ( [_Rev. Rec. Start Date], [_Rev. Rec. End Date], DAY ) ),
    BLANK (),
    DATEDIFF ( [_Rev. Rec. Start Date], [_Rev. Rec. End Date], DAY )
)and this:

_Rev. Rec. Term in Days =
IF (
    ISBLANK ( DATEDIFF ( [_Rev. Rec. Start Date], [_Rev. Rec. End Date], DAY ) ),
    0,
    DATEDIFF ( [_Rev. Rec. Start Date], [_Rev. Rec. End Date], DAY )
)

 

 

But still get the same error.

 

TIA,

Learner

2 REPLIES 2
HotChilli
Super User
Super User

Is this a calculated column or a measure?

DATEDIFF requires dates and when you add FORMAT you force it to a Text value, so start there.

All the _(underscore ones) are measures:

 

_Rev. Rec. Start Date
_Rev. Rec. End Date
_Rev. Rec. Term in Days
_Rev. Rec. Term in Months = DATEDIFF([_Rev. Rec. Start Date],[_Rev. Rec. End Date],MONTH)+1

So I created these measures because there was nulls in these date values coming from database and I had to subtract end date with the start date.

I think you have a point with FORMAT. So how would you propose to subtract days where we have nulls in the database without creating a measure?


Thanks for your help.

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors