Forum Discussion

TPGDIMO's avatar
TPGDIMO
New Member
3 years ago
Solved

Token Eof expected error

i wrote simple nested if statement in power query  editor.

 

it gives Token Eof expected error in highlighted possition. What is the reason

 

IF [Date.last.editted] > "01/04/2022" then "2022/2023"

else
IF [Date.last.editted] > "01/04/2021" then "2021/2022"
else
IF [Date.last.editted] > "01/04/2020" then "2020/2021"
else
IF [Date.last.editted] > "01/04/2019" then "2019/2020"
else
IF [Date.last.editted] > "01/04/2018" then "2018/2019"
else "2017/2018"

  • Hi - M/PowerQuery is case-sensitive, so it doesn't recognise "IF". Hopefully the below should work

     

    if [Date.last.editted] > "01/04/2022" then "2022/2023"
    
    else
    if [Date.last.editted] > "01/04/2021" then "2021/2022"
    else
    if [Date.last.editted] > "01/04/2020" then "2020/2021"
    else
    if [Date.last.editted] > "01/04/2019" then "2019/2020"
    else
    if [Date.last.editted] > "01/04/2018" then "2018/2019"
    else "2017/2018"

     

    I hope that helps!

1 Reply

  • m13eam's avatar
    m13eam
    Resolver III

    Hi - M/PowerQuery is case-sensitive, so it doesn't recognise "IF". Hopefully the below should work

     

    if [Date.last.editted] > "01/04/2022" then "2022/2023"
    
    else
    if [Date.last.editted] > "01/04/2021" then "2021/2022"
    else
    if [Date.last.editted] > "01/04/2020" then "2020/2021"
    else
    if [Date.last.editted] > "01/04/2019" then "2019/2020"
    else
    if [Date.last.editted] > "01/04/2018" then "2018/2019"
    else "2017/2018"

     

    I hope that helps!