Skip to main content
Solved

Create a column in table using If Function

  • May 15, 2023
  • 1 reply
  • 350 views

Acumen
Visitor

I’m very new to TimeXtender and was hoping someone could assist with my issues. 

 

How would you use an “If” function in TimeXtender?

For example, I need to create a new column in my table called “Quantity” . I then need to look at the [code] column in the same table and bring back a value using an If Function. 

Something like this:

If [code] = 1 then ‘small’ else if [code] = 2 then ‘medium’ else if [code] = 3 then ‘large else if [code] = 4 then ‘x large’ else null.

 

Thank you

Best answer by Thomas Lind

Hi Claire

Here is how I would do something like that in TimeXtender.

I would create three fixed values on the field and then add conditions to these fields.

It goes through the options in alphabetical order, so I do not need to add a condition to the last one. If the first two conditions do not apply it will just add this one. If I wanted to be sure it only got set if it had a value I would add a condition to this as well. Then if any given Type was different from the set options it would not be set with a value.

Here is how the transformation view looks if I set a condition on all three options.

As you can see the code generated is similar to what you would normally do for a IF statement in SQL.

1 reply

Thomas Lind
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • 1161 replies
  • Answer
  • May 15, 2023

Hi Claire

Here is how I would do something like that in TimeXtender.

I would create three fixed values on the field and then add conditions to these fields.

It goes through the options in alphabetical order, so I do not need to add a condition to the last one. If the first two conditions do not apply it will just add this one. If I wanted to be sure it only got set if it had a value I would add a condition to this as well. Then if any given Type was different from the set options it would not be set with a value.

Here is how the transformation view looks if I set a condition on all three options.

As you can see the code generated is similar to what you would normally do for a IF statement in SQL.