Forum Discussion

majdkaid22's avatar
majdkaid22
Helper V
10 years ago
Solved

custom column in M query

Hi guys, 

 

Am using the below formula to filter a particular column based on the last character in the group name 

 

if Text.End( Text.Upper( [Group] ), "S" )
then "A"
else "B"

 

it's returning with error

 

(Expression.Error: We cannot convert the value "S" to type Number.


Details:
Value=S
Type=Type

 

 

 

What does need to be fixed?

 

Thanks,

M

  • try this:

     

    if Text.End( Text.Upper( [Group] ), 1) = "S"
    then "A"
    else "B"

     

4 Replies

  • ImkeF's avatar
    ImkeF
    Community Champion

    try this:

     

    if Text.End( Text.Upper( [Group] ), 1) = "S"
    then "A"
    else "B"

     

    • majdkaid22's avatar
      majdkaid22
      Helper V

      thanks ImkeF 

       

      for me personal knowledge, why the ,1 made the difference? the goup column is text, hence I thought what I did was right

       

      Thanks mate

      Majd

      • ImkeF's avatar
        ImkeF
        Community Champion

        This is a syntax-error in the Text.End-formula (second argument need to be the number of letters to be returned - LinkToRessource) as well as in the conditional statment (when you use an if you need to combine it with an operator/comparer - LinkToRessource).