Forum Discussion

sgannon1's avatar
sgannon1
Frequent Visitor
10 years ago
Solved

'Token then expected' error

Hi all, 

 

Can anybody please tell me what 'token then expected' error means?

I have created the below formula (I am trying to allocated fiscal year to each month), but obviously I am doing something wrong.

 

 

 

  • Anonymous's avatar
    Anonymous
    10 years ago

    You're using DAX syntax to write a function in M. The query editor uses a different language. It should be

     

    =if [Month] > 9 then [Year] + 1 else [Year]

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    You're using DAX syntax to write a function in M. The query editor uses a different language. It should be

     

    =if [Month] > 9 then [Year] + 1 else [Year]

  • kcantor's avatar
    kcantor
    Community Champion

    This is referring to the proper set up of the if statement. It is not like excel. It needs a 'then' and and 'else' instead of commas.

    It should be:

    =if [Month]>9 then [year] + 1 else [year]

    If in PQL follws this format:

    = if <Logical_test> then <result> else <alternate_result>

    • Anonymous's avatar
      Anonymous
      Not applicable

      kcantor  or smpa01 See below If then error for custom column. It is only erroring out the first then- please advise how to fix this formula. thank you

      • Anonymous's avatar
        Anonymous
        Not applicable

        I figured it out nevermind. Once I removed all the ) before each of the thens the formula was accepted. Wish the error highlighted the ) parenthesis --calling it a token Then error is misleading bc the then is already there.