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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
TheBIGuy_PBI
Helper II
Helper II

Date Function returning error.

Hi, I have a calendar, where the dates are configured by using a function that looks for the earliest date from another table and starts the calendar by the first day of that year.  Then It's invoked.

Table Name is Daily Data)

1)
Function DailyDataRetMaxYear
= let
getDate = (table as table) =>
Date.Year(List.Max(table[DATE]))
in
getDate

2) Invoked here
Invoke DailyDataMaxYear = DailyDataRetMaxYear(#"Daily Data")
Result: it correctly returns the latest year from the table it's using

So in power query, I added it it to the first section of creating a calendar. Here's the first few lines of the code, and it works.

3)

let
// configurations start
Today=Date.From(DateTime.LocalNow()), // today's date
FromYear = DailyDataMinYear, // Use the invoke function here, to get Min Year
ToYear = DailyDataMaxYear, // Use the invoke function here, to get Max Year
StartofFiscalYear=7, // set the month number that is start of the financial year. example; if fiscal year start is July, value is 7
firstDayofWeek=Day.Monday, // set the week's start day, values: Day.Monday, Day, Sunday....
// configuration end
FromDate=#date(FromYear,1,1),
ToDate=#date(ToYear,12,31),
Source=List.Dates(
FromDate,
Duration.Days(ToDate-FromDate)+1,
#duration(1,0,0,0)
),

I can clearly see a calendar built based on my specs.
The problem is when I then close and apply this calendar, I get the following message

TheBIGuy_PBI_0-1681992775392.png

So if the calendar works find while building it in power query, why does it fail when I load it back?

Help is appreciated!

 

1 REPLY 1
v-yueyunzh-msft
Community Support
Community Support

Hi , @TheBIGuy_PBI 

According to your description, your error code is "OLE DB or ODBC error: Exception from HRESULT: 0x80040E1D ".

As searched , you can go to Data Model, refresh preview of the query and then apply changes. Make sure no errors in the query, sometime change of datatype in source conflict with query column data type especially date columns.

For more information , you can refer to this i hope it can help you:

Solved: OLE DB or ODBC error: Exception from HRESULT: 0x80... - Microsoft Power BI Community

OLE DB or ODBC error: Exception from HRESULT: 0x80040E1D | Power BI Exchange (pbiusergroup.com)

OLE DB or ODBC error: Exception from HRESULT: 0x80040E1D | Power bi Refresh Error دیدئو dideo

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

May 2025 Monthly Update

Fabric Community Update - May 2025

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