Forum Discussion

pmc086's avatar
pmc086
Frequent Visitor
6 years ago
Solved

If statement - Expression.Error: We cannot convert the value to type text

Trying to do what I figured was a simple nested if statement in power query. Use the 'add custom column' function to build this quickly.   The resultant M formula is:   = Table.AddColumn(#"Reorde...
  • Anonymous's avatar
    Anonymous
    6 years ago

    The datatype for the rows that are failing are numbers so the expression Text.Start([Grade Original],1) is returning the error. Either change the column type to text prior to adding the column or modify the formula as show below:

     

    = Table.AddColumn(#"Reordered Columns", "Grade", each if [Grade Original] = "Prep" then 0 else if Text.Start(Text.From([Grade Original]),1) = "7" then 7 else -1)