• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 561
  • Last Modified:

Color Fill expression SSRS

Hi Experts,

I want to add the expression for the textbox [MTDD1].
if [MTDD1] is nothing, shows  light grey;
if  [MTDD1] <[MTDS1], shows Red (in the attachment "preview", number 19 should show in red), otherwise shows CornflowerBlue.

I wrote the query, the SSRS can pass the expression, but the fill color did not apply. Can  anyone help me on it. Thanks.

=switch(Fields!Step.Value = "Total"   and Fields!MTDD1.Value<Fields!MTDS1.Value, "Red",  "CornflowerBlue",
 IsNothing(Fields!MTDD1.Value)
        ,"LightGrey"
    , True
        , Nothing
    )

PreviewDesign
0
tanj1035
Asked:
tanj1035
  • 2
1 Solution
 
ValentinoVBI ConsultantCommented:
Looks like your Switch parameters are not in the right order, they go like: condition 1, value 1, condition 2, value 2 and so on.

Try this:

=switch(Fields!Step.Value = "Total"   and IsNothing(Fields!MTDD1.Value)        ,"LightGrey"
    , Fields!Step.Value = "Total"   and Fields!MTDD1.Value < Fields!MTDS1.Value, "Red",
    , True        , "CornflowerBlue"
    )
0
 
tanj1035Author Commented:
Hi, Thanks for your reply.

I tried yours, but got the error message
"The BackgroundColor expression for the text box ‘MTDD1’ contains an error: [BC30588] Omitted argument cannot match a ParamArray parameter."

Actually, I am looking for the conditions like this
1)when Fields!Step.Value = "Total"   and Fields!MTDD1.Value<Fields!MTDS1.Value, IT HAS TO show "Red", otherwise "CornflowerBlue"
2)when [MTDD1] except Fields!Step.Value = "Total" is nothing, shows  light grey

I do not know if I express it clearly or not.  Looking forward to hearing from you.

Thanks.
0
 
ValentinoVBI ConsultantCommented:
I don't see why you would be getting that error, can you try troubleshooting by taking parts of the condition out of the expression and see if that works?  Or we could try writing the same logic differently:

=IIF(Fields!Step.Value = "Total",
  Switch( IsNothing(Fields!MTDD1.Value)        ,"LightGrey"
       , Fields!MTDD1.Value < Fields!MTDS1.Value, "Red"
       , True        , "CornflowerBlue"
     )
  , "CornflowerBlue"
)

BTW: the expression that I posted actually fulfills your stated requirements...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now