Forum Discussion

Roy_tap's avatar
Roy_tap
Helper I
4 years ago
Solved

Creating a new column using either custom or conditional column value

Hi,

 

I have an existing import table containing of date values as such:

ProcessStep NameLast UpdateStep aStep bStep cStep d
P1Step a01-01-0101-01-01   
P2Step b07-07-0103-03-0107-07-01  
P3Step a02-02-0102-02-01   
P4Step d06-06-0104-04-01  06-06-01
P5Step c05-05-0103-03-01 05-05-01 

 

How can I create a new column to replace the Last Update column in the Query Studio to meet the following condition:
When Step Name = Step b, Last Update will be replace with Step a value

When Step Name = Step d, Last Update will be replace with Step a value

Else = Last Update value

Final table should looks like this: (Highlighted value is the updated value)

ProcessStep NameLast UpdateStep aStep bStep cStep dLast Update1
P1Step a01-01-0101-01-01   01-01-01
P2Step b07-07-0103-03-0107-07-01  03-03-01
P3Step a02-02-0102-02-01   02-02-01
P4Step d06-06-0104-04-01  06-06-0104-04-01
P5Step c05-05-0103-03-01 05-05-01 05-05-01

 

Thanks.

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Roy_tap 

     

    add a custom column

     

    if [Step Name]="Step b" or [Step Name]="Step d" then [Step a] else [Last Update]

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Roy_tap 

     

    add a custom column

     

    if [Step Name]="Step b" or [Step Name]="Step d" then [Step a] else [Last Update]

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    In the formula bar, type:

     

    = Table.AddColumn(NameOfPriorStep, "Last Update 1", each if [Step Name] = "Step b" then [Step a] else if [Step Name] = "Step d" then [Step a] else [Last Update])

     

    --Nate