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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors