Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
maxLevel2
typeflat

...

Conditional operation that returns a specified value if the column field given as first argument (must be a Boolean field) shows true, and another value if it shows false.

How does it work in the search window?

Select Create column field in the search window toolbar, then select the Conditional operation. You need to specify three arguments:

Argument

Description

Data type

if mandatory

Boolean field that will be used as the base of your condition.

boolean

then mandatory

The value you specify here will be returned if the value of the Boolean

column

field is true.

Any

else mandatory

The value you specify here will be returned if the value of the Boolean

column

field is false.

Same than or compatible with the data type selected in then (for example, integer and float are compatible types)

The data type of the output values depends on the types selected in the then and else arguments.

Example

In the demosiem.logtrust.ecommerceweb.dataactivity table, we want to add a column field that shows the string Client error responsesDelayed response when the values in our statusCode column are 4xx or 5xx codesresponseTime field are above 1, and Succesful Timely response when they are 2xx1 or belowTo do itthis, we will create a new column using field using the Conditional operation but first, we need to create a Boolean column field that detects client error responses.delayed responses (above 1)..

Step 1: Detect client error responses

The first step is creating a Boolean column field that shows true when the codes numbers in the statusCode column are 4xx or 5xx responseTime field are above 1, and false when they are 2xx1 or below. To do itthis, we will add a new column using the Greater or equal (ge, >=) field using the greater than operation. Fill the arguments as follows, and enter a name for the column field (statusCode_typeresponseTime>1):

  • Value - statusCode column responseTime field

  • is greater than or equal to - Click the pencil icon and enter 400 1

...

Step 2: Create a new

...

field using the Conditional operation

Select Create columnfield on the query toolbar, then select Conditional as the operation. Fill the arguments as follows, and enter a name for the column field (responseTyperesponseTimeDuration):

  • if - statusCode_type column responseTime>1 field

  • then - Click the pencil icon and enter Client error Delayed response

  • else - Click the pencil icon and enter Successful Timely response

...

Click Create columnfield and you will get the following result:

...

Use the operator select... as...  and add the operation syntax to create the new columnfield. See below the syntax for the Conditional operation. Keep in mind that value1 is the value that will be returned when the Boolean column field shows true, and value2 when it shows false.

  • ifthenelse(boolean, value1_true, value2_false)

Example

You can copy the following LINQ script and try the above example on the demosiem.logtrust.ecommerceweb.dataactivity  table. 

Code Block
from demosiem.logtrust.ecommerceweb.dataactivity
  select statusCoderesponseTime > 4001 as statusCode_type`responseTime>1`,
    ifthenelse(statusCode_type`responseTime>1`, "ClientDelayed error response", "SuccessfulTimely response") as responseTyperesponseTimeFrame