excelpowerbipowerquerypowerbi-desktopm

custom column based on the length


I am trying to add a custom column based on the length of the Text column which is column 1 (which contains text and ID numbers). but the code below gives this error.

Expression.Error: We cannot apply field access to the type Function.

Is there a way to fix this ?

  #"Added Custom" = Table.AddColumn(#"previous stem", "Custom", each if Text.Length[column1] <> 6 then [column2] else[column3])

enter image description here


Solution

  • Try just adding this to the custom column dialogue.

    if Text.Length([column1]) <> 6 then [column2] else[column3]