Forum Discussion
"An unexpected error occurred (file '', line , function '')" error
Hello,
I'm unable to use DATE(year,month,day) function because I'm getting this error
An unexpected error occurred (file '', line , function '')
please advise
Thanks,
Karoon
Hi kgayzagian ,
make sure that you choose the columns of your table, Date('Table'[year], 'Table'[month], 'Table'[Day]) not the year() function, and also make sure that they are in date format and you dont have any null values in these columns. If this doen't help please upload your exact formula and error (screenshots).
If this post helps, then I would appreciate a thumbs up 👍 and mark it as the solution ✔️ to help the other members find it more quickly.
4 Replies
- Prince0011Solution Sage
The DATE(year, month, day) function is valid DAX, so the error:
An unexpected error occurred (file '', line , function '')
is not a normal DAX syntax error. It usually indicates an internal issue with Power BI Desktop, the model, or the expression being evaluated.
Here are a few things to check:
1. Verify the syntax
Ensure you're using the correct DAX syntax, for example:
New Date = DATE(2026, 7, 22)
Or, if you're using columns:
New Date = DATE( 'Table'[Year], 'Table'[Month], 'Table'[Day] )Make sure the Year, Month, and Day columns are numeric.
2. Check for invalid values
The DATE() function expects valid integer values:
Year: e.g., 2026
Month: 1–12
Day: valid for the given month
If any column contains blanks, text, or invalid numbers, try handling them first:
New Date = IF( AND( NOT(ISBLANK('Table'[Year])), NOT(ISBLANK('Table'[Month])), NOT(ISBLANK('Table'[Day])) ), DATE('Table'[Year], 'Table'[Month], 'Table'[Day]) )3. Confirm where you're using DATE()
Is this in:
A calculated column?
A measure?
A calculated table?
Knowing the context can help identify the cause.
4. Update Power BI Desktop
If even a simple expression like:
Test = DATE(2026, 1, 1)
returns the same error, it may be a Power BI Desktop issue. Updating to the latest version or repairing/reinstalling Power BI Desktop often resolves unexpected internal errors.
5. Check the model
If the error occurs only in one PBIX file:
Create a new PBIX.
Create a small sample table.
Test DATE(2026,1,1).
If it works in the new file, the original model may be corrupted.
If you can share:
The exact DATE() formula you're using.
Whether it's a measure or calculated column.
Your Power BI Desktop version.
it will be easier to identify the root cause.
💡 Helpful? Give a Kudos 👍 — keep the community growing.
✅ Solved your issue? Mark this as the Accepted Solution ✔️
Best regards, Prince Singh | Data Science & Microsoft Fabric Enthusiast
- Selva-SalimiSolution Sage
Hi kgayzagian ,
make sure that you choose the columns of your table, Date('Table'[year], 'Table'[month], 'Table'[Day]) not the year() function, and also make sure that they are in date format and you dont have any null values in these columns. If this doen't help please upload your exact formula and error (screenshots).
If this post helps, then I would appreciate a thumbs up 👍 and mark it as the solution ✔️ to help the other members find it more quickly.
- kgayzagianNew Member
thank you so much Selva. I will try it
- kgayzagianNew Member
thank you all. appreciate your help