Adding an Enumeration type calculated field

Here we want to create a query with an Enumerations type calculated field. This field will generate an additional column in the data preview window. This column will specify the numeric values returned as a result for each recipient (0, 1 and 2). A gender will be assigned to each value in the new column: “Male” for “1”, “Female” for “2” or “Not indicated” if the value equals “0”.

  • Which table needs to be selected?

    The recipient table (nms:recipient)

  • Fields to be selected in the output column?

    Last name, First name, Gender

  • Criteria which the information will be filtered based on?

    The rrecipient language

Apply the following steps:

  1. Open the Generic query editor and select the Recipient table (nms:recipient).

  2. In the Data to extract window, select Last name, First name and Gender.

  3. In the Sorting window, click Next: no sort is necessary for this example.

  4. In Data filtering, select Filtering conditions.

  5. In the Target element window, set a filter condition to collect recipients who speak English.

  6. In the Data formatting window, click Add a calculated field.

  7. Go to the Type window of the Export calculated field definition window and select Enumerations.

    Define the column which the new calculated field must refer to. To do this, select the Gender column in the drop-down menu of the Source column field: the destination values will coincide with the Gender column.

    Define the Source and Destination values: the destination value makes the query result easier to read. This query should return recipient gender and the result will either be 0, 1, or 2.

    For each “source-destination” line to be entered, click Add in the List of enumeration values:

    • In the Source column, enter the source value for each gender (0,1,2) in a new line.
    • In the Destination column, enter the values: “Not indicated” for line “0”, “Male” for line “1”, and “Female” for line “2”.

    Select the Keep the source value function.

    Click OK to approve the calculated field.

  8. In the Data formatting window, click Next.

  9. In the preview window, start the preview of the data.

    The additional column defines the gender of 0, 1 and 2:

    • 0 for “Not indicated”
    • 1 for “Male”
    • 2 for “Female”

    For example, if you don’t enter gender “2” in the List of enumeration values, and the Generate a warning and continue function of the In other cases field is selected, you will get a warning log. This log indicates that gender “2” (Female) has not been entered. It is displayed in the Logs generated during export field of the data preview window.

    Let’s take another example and say that enumeration value “2” isn’t entered. Select the Generate an error and reject the line function: all gender “2” recipients will raise anomalies and the other information in the line (first and last name, etc.) will not be exported. An error log is displayed in the Logs generated during export field of the data preview window. This log indicates that enumeration value “2” isn’t entered.

On this page