Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Create a column with Condition.

Hello,

 

I have a column with Product numbers that are as follows 6500N,76MR1,9ES00A and from these i would derive the Product Type as if the Product Number start with '65' then the Product Type is a,if starts with '76' then B and if starts with '9' then C.How do i do this the easiest way

  • Anonymous's avatar
    Anonymous
    6 years ago

    In the PowerQuery window, you could click on the Add Column tab in the ribbon and choose a conditional column.

     

     

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    The original Code created by Power Query was this:

    1. = Table.AddColumn(_Customers, "Custom", each Date.Year([BirthDate]), type number)

    I simply changed the code directly in the Formula Bar to be like this:

    = Table.AddColumn(_Customers, "Age", each 2016 - Date.Year([BirthDate]), type number)
     
  • Anonymous's avatar
    Anonymous
    Not applicable

    In the PowerQuery window, you could click on the Add Column tab in the ribbon and choose a conditional column.