Forum Discussion

olitetu's avatar
olitetu
Regular Visitor
6 years ago
Solved

Adding custom column with If function

I'm trying to add a column returning values depending on which range another column's value fits in.   I tried the following: = Table.AddColumn(#"Renamed Columns", "Recence Groupe", each if [Rece...
  • edhans's avatar
    edhans
    6 years ago

    is the [Recence] field a string? if so, it should say 

    if Number.From([Recence]) < 30, etc.

     

    You cannot compare numbers to text. You will get errors. I suspect it is because before you were getting no errors, so [Recence] must be text as well.

     

    Additionally, if [Recence] should be a number all the way round, just convert the field to a number. In the upper left of the column it probalby has ABC for text. Click on that and convert it to either a decimal number or whole number. Then you don't have to use Number.From() around it. Do that very early in your Power Query steps, before adding any custom columns.