Search code examples
excelpowerbipowerquerypowerbi-desktopm

Error in simple if else statement in Power Query


I have the following line written in m.

= Table.AddColumn(#"Grouped Rows", "Custom", each if [Count] mod 5 = 0 then 0 else 1)

The error I am getting is Expression.SyntaxError: Token 'then' expected.

This makes no sense, since the syntax is correct.

This is what I see:enter image description here


Solution

  • Do you mean this?

    = Table.AddColumn(#"Grouped Rows", "Custom", each if Number.Mod([Count],5) = 0 then 0 else 1)