Search code examples
powerquerym

Token literal in Powerquery M formula


I am getting an Token Literal expected error on the following powerquery M formula. The error is pointing at the part between **

if 
(if [Value 1] = true then [Value 2] - [Value 3] else [Value 3] - [Value 4]) < [Value 1] and 
**if** 
(if [Value 1] = true then [Value 2] - [Value 3] else [Value 3] - [Value 4]) > 0 then 1 else 

Please note this is this a part of a bigger formula, but only this part gives an error. 

Does anyone has an idea how to solve this? 

Solution

  • Its hard to tell without the formula end after the last else (I assume 0) but removing the extra IF should work

    if

    (if [Value 1] = true then [Value 2] - [Value 3] else [Value 3] - [Value 4]) < [Value 1]

    and

    (if [Value 1] = true then [Value 2] - [Value 3] else [Value 3] - [Value 4]) > 0

    then 1 else 0