Cowthulhu
Cowthulhu

Reputation: 528

Execute Returned Data as Expression

I have a (shared) dataset that, when selected via

=First(Fields!TableColumn.Value, "DatasetName")

will return something similar to

=IIF(ROWNUMBER(NOTHING) MOD 2, "WHITE", "WHITESMOKE")

I am trying to use this such that I can have multiple reports with dynamic, expression based formatting (mainly in row background color) that I can update by modifying a single record in a dataset. The issue is that Report Builder does not seem to want to execute this code, and instead interprets it as a escaped string. Is there any way to specify this should be executed as an expression?

I've tried:

=IIF(ROWNUMBER(NOTHING) MOD 2, "WHITE", "WHITESMOKE")
IIF(ROWNUMBER(NOTHING) MOD 2, "WHITE", "WHITESMOKE")
"=IIF(ROWNUMBER(NOTHING) MOD 2, "WHITE", "WHITESMOKE")" 
"IIF(ROWNUMBER(NOTHING) MOD 2, "WHITE", "WHITESMOKE")"

Upvotes: 2

Views: 78

Answers (1)

Daniel
Daniel

Reputation: 1364

I don't believe that SSRS will interpret your field value as an expression and will instead always treat it as a string.

However, to achieve what you are looking to do, what about breaking this up into smaller pieces.

Shared dataset named "colors":

SELECT 'WHITE' as color1, 'WHITESMOKE' as color

Expression for background color:

=IIF(
   ROWNUMBER(NOTHING) MOD 2,
   First(Fields!Color1.Value, "Colors"), 
   First(Fields!Color2.Value, "Colors"))

Upvotes: 2

Related Questions