Which expression yields the desired outcomes?

Data from an Excel file is read into a data table named "dtEmployee", as displayed in the following graphic:

A developer needs to filter the data table to obtain all rows representing employees from the Finance and IT departments with a Salary under 30,000.

Which expression yields the desired outcomes?
A . dtEmployee.Select("([Department]=’IT’ AND [Department]=’Finance’) AND [Salary] < 30000")
B . dtEmployee.Select("[Department]=’IT’ OR [Department]=’Finance’ AND [Salary] < 30000")
C . dtEmployee.Select("([Department]=’IT’ OR [Department]=’Finance’) AND [Salary] < 30000")
D . dtEmployee.Select("[Department]=’IT’ OR [Department]=’Finance’ OR [Salary] < 30000")

Answer: C

Explanation:

This expression filters the data table to obtain all rows representing employees from the Finance and IT departments with a Salary under 30,000. The expression uses the Select method of the data table, which returns an array of data rows that match a specified condition. The condition is written as a string that follows the syntax and rules of the DataColumn.Expression property. The condition uses parentheses to group the logical operators OR and AND, which have different precedence levels. The OR operator returns true if either operand is true, while the AND operator returns true only if both operands are true. The condition also uses single quotes to enclose the string values of the Department column, and the less than operator to compare the numeric values of the Salary column. (UiPath Studio documentation1)

References: 1: DataTable.Select Method (System.Data) | Microsoft Docs.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments