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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How to replace null values in datetime values

Hello, I know this issue has been raised so many times on this formu, I tried to work on that and use your solutions to my code, but with no success. During the refreshing I face this bug:
OLE DB or ODBC error: [Expression.Error] We cannot convert the value null to type Logical.. An unexpected exception occurred.
I assume, the problem is here:

suspender_0-1658996142525.png

I have the column with a date (data type: Date/Time) and with some rows this date is empty, which is fine, I cannot remove these ones. But how can I replace these values? I think that adding the new column does not solve my problem, because during the refreshing the issue will occur anyway. How to fix it?



1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Approve with @amitchandak , when there is null value in a data column, it won’t get error.

vjianbolimsft_0-1659490085206.png

 

It seems that you used the null value in somewhere else?

Please try to replace these null values with 9999/12/31

vjianbolimsft_1-1659490085208.png

 

vjianbolimsft_2-1659490085209.png

 

Here is the M code:

let

    Source = Excel.Workbook(File.Contents("C:\xxx\New Microsoft Excel Worksheet.xlsx"), null, true),

    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],

    #"Changed Type" = Table.TransformColumnTypes(Sheet1_Sheet,{{"Column1", type date}, {"Column2", type number}}),

    #"Replaced Value" = Table.ReplaceValue(#"Changed Type",null,#date(9999, 12, 31),Replacer.ReplaceValue,{"Column1"})

in

    #"Replaced Value"

Final output:

vjianbolimsft_3-1659490085213.png

 

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Approve with @amitchandak , when there is null value in a data column, it won’t get error.

vjianbolimsft_0-1659490085206.png

 

It seems that you used the null value in somewhere else?

Please try to replace these null values with 9999/12/31

vjianbolimsft_1-1659490085208.png

 

vjianbolimsft_2-1659490085209.png

 

Here is the M code:

let

    Source = Excel.Workbook(File.Contents("C:\xxx\New Microsoft Excel Worksheet.xlsx"), null, true),

    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],

    #"Changed Type" = Table.TransformColumnTypes(Sheet1_Sheet,{{"Column1", type date}, {"Column2", type number}}),

    #"Replaced Value" = Table.ReplaceValue(#"Changed Type",null,#date(9999, 12, 31),Replacer.ReplaceValue,{"Column1"})

in

    #"Replaced Value"

Final output:

vjianbolimsft_3-1659490085213.png

 

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

This is works for this column, thank you

Anonymous
Not applicable

Maybe the problem is elsewhere, I don't know how to find exactly where the problem is. Could you please advise me?

amitchandak
Super User
Super User

@Anonymous , date column should not give that issue. It should be some boolean column.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak Could you please advise me how to add boolean column?

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.