Forum Discussion
if statement in a new column not working
- 7 years ago
Hi benjamin_sasin ,
Yep, it is only syntax problem, please try instead:
if [GRADYYYYMM] = null or Text.Length([GRADYYYYMM]) < 6 then null else Date.FromText(Text.Combine({Text.Start([GRADYYYYMM],4),Text.End([GRADYYYYMM],2),"01"},"-"))IF SYNTAX in M Language:
if <test> then <output1> else <output2>
NESTED SYNTAX (just append the if after else and everything is the same):
if <test> then <output1> else if <test2> then <output2> else if <test3> then <output3> else <output4>
Any question, just let me know,
Regards,
Gian Carlo Poggi
Hi benjamin_sasin ,
Yep, it is only syntax problem, please try instead:
if
[GRADYYYYMM] = null or Text.Length([GRADYYYYMM]) < 6
then
null
else
Date.FromText(Text.Combine({Text.Start([GRADYYYYMM],4),Text.End([GRADYYYYMM],2),"01"},"-"))IF SYNTAX in M Language:
if <test> then <output1> else <output2>
NESTED SYNTAX (just append the if after else and everything is the same):
if <test> then <output1> else if <test2> then <output2> else if <test3> then <output3> else <output4>
Any question, just let me know,
Regards,
Gian Carlo Poggi
- benjamin_sasin7 years ago
Resolver I
I forgot the "then"--duh (facepalm)! Thanks a lot!