Of the M language coding options, the Custom Column feature is probably the most commonly used.


Custom Columns contain a warning at the bottom of the screen to help guide you with our formulas:



The screenshot above shows the Token RightParen expected message.  This is just one of many potential messages.  As we type into the formula box, the message will changes so check this once the formula finished.  If the Show error option is visible, click it to take you to exactly where the problem is.


The most common warnings are:


  • Token Literal expected means the next thing in the formula is expected to be a value, column name, or a function.
  • Token Then expected, or Token Else expected means the words then or else are expected to be entered next.  These will appear when writing an if statement.
  • Token RightParen expected means that a closing bracket, or parentheses depending on your local vernacular, is expected to close a formula.
  • A Comma cannot precede a RightParen means what it says; a comma cannot be directly in front of a closing bracket, there are no circumstances in M where this should be necessary.
  • Invalid literal indicates there is an issue with the value entered as the literal (this often occurs when a test string has not been closed using the double quotation character.
  • Token EoF expected usually occurs when an invalid function name is used, or it uses the wrong case (for example, if is a valid command, while If with an upper case I is invalid).
  • The formula is incomplete is usually an indication that no formula has been entered (only the equals symbol in the formula box).


The newer versions for Power Query include IntelliSense, which significantly reduces the risk of error.  It helps to identify the arguments and data types required for each function, but also helps to minimise typos.


Once you see the message which says No syntax errors have been detected, click the OK button to close the window. 


Remember, this does not mean the formula or data types are correct, but that the syntax has been entered correctly.