SSRS Choose Function

The SSRS Choose function is a Program Flow function that helps you choose a single value from multiple options. For instance, you could choose a main phone number from the list of employee phone numbers.

The syntax of the SSRS Choose function accepts at least two arguments, as shown below. The first argument is the index position, which is used to choose the argument. The second one is a list of items separated by a comma. For example, if the first argument is 2, it chooses the second list item (20 from the below example).

=Choose(2, "10","20","30")
=Choose(Datepart("w", Fields!HireDate.Value), "First", "Second", "Third", "Fourth", "Fifth", "Sixth", "Seventh")

We use the Employee table below, which has 15 records, to demonstrate the SSRS Choose function. The image shows the records in the Table report.

Inspection Source Table

SSRS Choose function Example

For this, let me add a new column to the right side of the BirthDate column. Next, right-click the textbox under the Choose header and select the Expression option. To understand the report, I suggest you refer to the articles on charts, tables, grouping, and format tables in SSRS.

Select the expression option

It opens the following expression window to pick one value. The below DatePart function extracts the quarter from the BirthDate column and returns an integer value between 1 and 4. Next, the SSRS Choose function will pick the appropriate string information from the list of four items.

=Choose(DatePart("q", Fields!BirthDate.Value),
"1st Quarter", "2nd Quarter", "3rd Quarter", "4th Quarter")
SSRS Choose Function expression

From the below report preview, you can see the messages.

SSRS Choose Function report preview

Apart from the above functionality, you cause the SSRS Choose function to alter or change the background or font colors. To demonstrate this, let me change the background color. For this, select the details row and go to the BackgroundColor in the property window. Next, choose the expression option and write the below expression to change the background color based on the remainder.

=Choose(RowNumber(Nothing) Mod 4, "LightGreen", "Plum", "Orange")
SSRS Choose Function expression to change background color

Please click the preview tab to see the report.

SSRS Choose Function Expression to change the report background color