Search code examples
reporting-servicesssrs-2008background-colorssrs-2012

Union expression background color SSRS 2012


I have a ssrs report the report contains 2 tables

Table 1 contains an expression for background color cells:

=iif((Fields!FIO.Value.ToString() like "*high*")
or (Fields!FIO.Value.ToString() like "*temp*"),"#ff8989", "White" )

Table 2 contains an expression for background color cells

=iif(Fields!Fields.Value < 0, "#A1e7cf", "White")

I want to add expression to the current expressions: =Iif(RowNumber(Nothing) Mod 2, "LightGrey" , "Transparent") but I do not know how to unite them, Google could not help me.

how to union 2 expressions for table 1:

=iif((Fields!FIO.Value.ToString() like "*high*")
or (Fields!FIO.Value.ToString() like "*temp*"),"#ff8989", "White" )
AND
=Iif(RowNumber(Nothing) Mod 2, "LightGrey" , "Transparent")

for table 2

=iif(Fields!Fields.Value < 0, "#A1e7cf", "White")
AND
=Iif(RowNumber(Nothing) Mod 2, "LightGrey" , "Transparent")

Solution

  • Assuming your syntax is correct, you could combine the logic like this:

    =Switch(Fields!FIO.Value.ToString() like "high" or Fields!FIO.Value.ToString() like "temp", "#ff8989"
    , RowNumber(Nothing) Mod 2, "LightGrey"
    , true , "White" ) 
    
    =Switch(Fields!Fields.Value < 0, "#A1e7cf", "White"
    , RowNumber(Nothing) Mod 2, "LightGrey"
    , true , "Transparent")
    

    A Switch is like a series of IIf statements. It has pairs of conditions and results. The result for the first true condition will be selected. You can follow this pattern to adjust the behavior as needed.