locked
RDLC and Conditional formatting for Cell RRS feed

  • Question

  • User-10017267 posted

    I am using a ReportViewer control and have to set the Cell colour is based on the contents of the cell (conditional formatting) and the cell content can take one value;

    [First(CompletedDateTime)]

    This content is formatted to System.String in the RDLC

    But the cell takes on an integer value if it is not a date.

    i.e.

    'Feb 13 2012 5:11PM'

    or -33

    or 27

    or -244

    etc.

    I want it to be blue if it shows a date, and then other colours depending on the value of the integer.

    i.e. for this expression:

    = iif(InStr(Fields!CompletedDateTime.Value, "M") > 0 ,"Blue","")

    The Cell goes blue !! Great.

    But when I write this expression:

    =    iif(InStr(first(Fields!CompletedDateTime.Value), "M") > 0 ,"Blue",
        iif(first(Fields!CompletedDateTime.Value) >= 14, "Green",
        iif(first(Fields!CompletedDateTime.Value) >= 0 ,"Yellow",
        iif(first(Fields!CompletedDateTime.Value) < 0 , "Red", "Blue"
        ))))

    I get all of the colours except blue.......

    I believe it is because the first if statement is treating the cell value as a string, and subsequently the others are treating the cell value as an integer.

    This problem I can't seem to work out. I have tried just about every technique available but I can't get the four colours going as above.

    Any ideas?

    p.

    Wednesday, February 22, 2012 1:49 AM

Answers

  • User-10017267 posted

    This has been my only solution so far

    =   iif(instr(first(Fields!CompletedDateTime.Value) ,"M") > 0 , "PowderBlue",
        iif(first(Fields!CompletedDateTime.Value) = "1","Yellow",
        iif(first(Fields!CompletedDateTime.Value) = "2","Yellow",
        iif(first(Fields!CompletedDateTime.Value) = "3","Yellow",
        iif(first(Fields!CompletedDateTime.Value) = "4","Yellow",
        iif(first(Fields!CompletedDateTime.Value) = "5","Yellow",
        iif(first(Fields!CompletedDateTime.Value) = "6","Yellow",
        iif(first(Fields!CompletedDateTime.Value) = "7","Yellow",
        iif(first(Fields!CompletedDateTime.Value) = "8","Yellow",
        iif(first(Fields!CompletedDateTime.Value) = "9","Yellow",
        iif(first(Fields!CompletedDateTime.Value) = "10","Yellow",
        iif(first(Fields!CompletedDateTime.Value) = "11","Yellow",
        iif(first(Fields!CompletedDateTime.Value) = "12","Yellow",
        iif(first(Fields!CompletedDateTime.Value) = "13","Yellow",
        iif(first(Fields!CompletedDateTime.Value) = "14","Yellow",
         iif(instr(first(Fields!CompletedDateTime.Value) ,"-") > 0 , "Red","Green"))))))))))))))));

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 22, 2012 6:56 PM