Sunday, October 11, 2015

SSRS difference between IIF and Switch Function

he SWITCH function allows you to have multiple conditions when evaluating an expression. It evaluates each condition within the function. It will ignore rest of condition once it finds first True condition.

A common example of this is when you want to format your background color of a cell or row to one of three or more colors depending on the value of a field. Using nested IIFs that statement might look something like this:

=IIF(Fields!something.Value=1, ”Blue”, IIF(Fields!something.Value=2, ”White”, IIF(Fields.something.Value=3, ”Red”, ”Green”)))

With the SWITCH function your syntax will look like this:

Fields!something.Value=1, “Blue”,
Fields!something.Value=2, “White”,
Fields!something.Value=3, “Red”,
True, “Blue”

In the example above, you can see that we are using True to simulate the ELSE condition in the standard CASE statement.

Keywords: SSRS Interview Questions , SSRS Interview Questions and answers, SQL Server Reporting Services Interview Questions

No comments:

Post a Comment