Are you dealing with the expression.syntaxerror: token eof expected error message in your code?
This error message is commonly seen in programming languages like Python and JavaScript.
In this article, we will help you understand what this error is all about and how to resolve it.
Continue to read on to find step-by-step solutions to get rid of the expression.syntaxerror token eof expected error message.
What is “expression.syntaxerror: token eof expected”?
The expression.syntaxerror: token eof expected is an error message that can occur in Power Query.
It usually occurs when an invalid function name is used or it uses the wrong case (for instance, “if” is a valid command, while “If” with an upper case “I” is not).
In simple words, the token eof expected usually occurs when an invalid function name is used, or it uses the wrong case.
Why does “expression.syntaxerror: token eof expected” error message occur?
This error message occurs due to several factors, such as:
👉 Forget to include a closing bracket or parenthesis in your code. This can lead you to an incomplete expression and trigger the error.
👉 Leaving a string or comment open without closing it.
👉 Forgetting to add a semicolon at the end of a statement can result in a syntax error.
How to fix “expression.syntaxerror: token eof expected”?
To fix the expression.syntaxerror: token eof expected error message in Power Query.
Here are some ways to fix this error:
- Check if an invalid function name is used or if it uses the wrong case, as we mentioned above (if is a valid command, while If with an upper case, I is not).
Incorrect code:
let
Source = "Hi, welcome to itsourcecode",
Result = If(Source = "Hi, welcome to itsourcecode", "Yes", "No")
in
Result
Corrected code:
let
Source = "Hi, welcome to itsourcecode",
Result = if(Source = "Hi, welcome to itsourcecode", "Yes", "No")
in
Result
- Ensure you have a good understanding of how Power Query works.
Incorrect code:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Result = Table.AddColumn(Source, "Custom", each [Column1] + [Column2])
in
Result
Corrected code:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Result = Table.AddColumn(Source, "Custom", each [Column1] + [Column2])
in
Result
- If you’re using Custom Columns, check the syntax check at the bottom of the screen to help guide you with formulas.
Incorrect code:
Custom Column formula: [Column1] + [Column2
Corrected code:
Column formula: [Column1] + [Column2]
- You can also check if there are any errors in the M code or if there is a lack of understanding of how Power Query works.
Note: Note: The Power Query IF, THEN, and IF ELSE statements are case-sensitive and they require lower-case. You should change “if,” “then,” and “else” in lowercase.
Conclusion
In conclusion, the expression.syntaxerror: token eof expected is an error message that can occur in Power Query.
It usually occurs when an invalid function name is used or it uses the wrong case (for instance, “if” is a valid command, while “If” with an upper case “I” is not).
This article already provides solutions to fix this error message. By executing the solutions above, you can master this SyntaxError with the help of this guide.
You could also check out other SyntaxError articles that may help you in the future if you encounter them.
- Syntaxerror: cannot use ‘import.meta’ outside a module
- Uncaught syntaxerror invalid left-hand side in assignment
- Syntaxerror: multiple exception types must be parenthesized
We are hoping that this article helps you fix the error. Thank you for reading itsourcecoders 😊