Microsoft 365 and Office | Development | Other
Building custom solutions that extend, automate, and integrate Microsoft 365 apps.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have encountered a "Token Literal Expected" error in the second "if" of this formula. The formula is:
D4= 0.035,
D5= 0.05,
D6= 0.07,
E4= 1,
E5= 0.9,
E6= 0.8,
Result =
if((1-(1-if[#"% CR"]<=D4 then 1 else if [#"% CR"]<=D5 then (1-([#"% CR"]-D4)/((D5-D4)/(E4-E5))) else if [#"% CR"]<=D6 then (E5-([#"% CR"]-D5)/((D6-D5)/(E5-E6)) else 0)*2))=-1 then 0 else (1-(1-if [#"% CR"]<=D4 then E4 else if [#"% CR"]<=D5 then (E4 -([#"% CR"]-D4)/((D5-D4)/(E4-E5)) else if[#"% CR"]<=D6 then E5-([#"% CR"]-D5)/((D6-D5)/(E5-E6)) else 0)*2)))
in
Your code does not correctly match the left and right paren.
Correcting the code to what I assume is the correct code would look like below.
let
D4= 0.035,
D5= 0.05,
D6= 0.07,
E4= 1,
E5= 0.9,
E6= 0.8,
Result =
if (
(1-
(1-
(if [#"% CR"]<=D4
then
1
else
if [#"% CR"]<=D5
then
(1-
([#"% CR"]-D4)
/
((D5-D4)/(E4-E5))
)
else
if [#"% CR"]<=D6
then
(E5-
([#"% CR"]-D5)
/
((D6-D5)/(E5-E6))
)
else
0
)*2
)
) =-1
)
then
0
else
(1-
(1-
(if [#"% CR"]<=D4
then
E4
else
if [#"% CR"]<=D5
then
(E4 -
([#"% CR"]-D4)
/
((D5-D4)/(E4-E5))
)
else
if [#"% CR"]<=D6
then
E5-
([#"% CR"]-D5)
/
((D6-D5)/(E5-E6))
else 0
)*2
)
)
in
Result