locked
SSRS Expressions, Font Colour Change RRS feed

  • Question

  • User976103969 posted

    HI,

    i am having some difficulty trying to get my text to change based on an expression / rule.

    how can i do this based on my example from access:

    =Switch (Fields!StatusSummary ="GIVEBACK" And Fields!StatusLastChanges <Now()-42, "Red",

    Fields!StatusSummary ="GIVEBACK" And Fields!StatusLastChanged <Now()-21 And Fields!StatusLastChanges>Now()-42, "Amber",

    Fields!StatusSummary ="GIVEBACK" And Fields!StatusLastChanges>()-21, "Green" )

     - this changes colour depending on the rule. red, amber and green.

    how can i do this in SSRS?

     

    Thursday, May 30, 2013 9:34 AM

Answers

  • User-67082742 posted

    Go to the font properties of the field you intend to change the color on and then write an expression on Color property of font :

    = Switch( Fields!StatusSummary = "Giveback" and Fields!statusLastChanges < Date() - 42 , "Red",

                     Fields!StatusSummary = "Giveback" and Fields!statusLastChanges < Date() - 42 ,"Amber",

                     Fields!StatusSummary = "Giveback" and Fields!statusLastChanges < Date() - 42 ,"Green"

                   )

    The switch expression works like " Switch( Condition1, Result1,

                                                                           Condition2 , Result2,

                                                                          ...etc)

    You might need to change the fields and add date conversion in above expression to work as you need.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 31, 2013 8:15 AM

All replies

  • User-67082742 posted

    Go to the font properties of the field you intend to change the color on and then write an expression on Color property of font :

    = Switch( Fields!StatusSummary = "Giveback" and Fields!statusLastChanges < Date() - 42 , "Red",

                     Fields!StatusSummary = "Giveback" and Fields!statusLastChanges < Date() - 42 ,"Amber",

                     Fields!StatusSummary = "Giveback" and Fields!statusLastChanges < Date() - 42 ,"Green"

                   )

    The switch expression works like " Switch( Condition1, Result1,

                                                                           Condition2 , Result2,

                                                                          ...etc)

    You might need to change the fields and add date conversion in above expression to work as you need.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 31, 2013 8:15 AM
  • User976103969 posted

    Hi Abhi.ssrs, thank you for the reply.

    switch looks like the way i need to go. the problems i am running into are changing Date to Today() or Now() and adding the -42.

     

    =Switch (Fields!StatusSummary =

    "GIVEBACK" And Fields!StatusLastChanges <Now()-42, "Red",

    Fields!StatusSummary =

    "GIVEBACK" And Fields!StatusLastChanged <Now()-21 And Fields!StatusLastChanges>Now()-42, "Amber",

    Fields!StatusSummary =

    "GIVEBACK" And Fields!StatusLastChanges>()-21, "Green" )

    Errors when i run the report

    "The Color expression for the textrun 'StatusSummary.Paragraphs[0].TextRuns[0]' contains an error: [Bc30518]: overload resolution failed because no accessinle '=' can be called with rhese arguments"

    - 42 gets me an error '-' not a valid expression and a syntax error for Today() and Now(), how could i fix these problems?

     

    thank you

    Friday, May 31, 2013 9:36 AM
  • User-67082742 posted

    Hi, Sorry for the delayed response.

    The adte operation can be handled like

    =IIF(CDate("4/21/2012")< DateAdd(DateInterval.Day, - 40,Globals!ExecutionTime) , True,False)

    In Your case try this as a switch  :

    Switch(CStr(Fields!StatusSummary) ="GIVEBACK" And CDate(Fields!StatusLastChanges) < DateAdd(DateInterval.Day, - 42,Globals!ExecutionTime), "Red",

    ....)

    Lemme know if this doesn't help

    Monday, June 3, 2013 1:05 AM
  • User976103969 posted

    Hi,

    i have come back to this part of my project to try and get this working, is anybody able to shine some more light on how i can get this working?

    Again  i need to to work like below: 

    =Switch (Fields!StatusSummary ="GIVEBACK" And Fields!StatusLastChanges <Now()-42, "Red",

    Fields!StatusSummary ="GIVEBACK" And Fields!StatusLastChanged <Now()-21 And Fields!StatusLastChanges>Now()-42, "Amber",

    Fields!StatusSummary ="GIVEBACK" And Fields!StatusLastChanges>()-21, "Green" )

    Thanks in advance!

    Monday, June 3, 2013 7:28 AM