none
Backgound color for the first three

    Question

  • Hi guys, one question: I have a table with 8 row, each row a different value like this:

    ita  85

    fra  83

    usa 80

    ger 70

    chi  55

    now I would like to set the background different for ita (first, yellow), fra (second silver) and usa (third bronze). I tried with 

    =Switch(

    Fields!bac.Value = max(Fields!bac.Value), "yellow", "white"

    )

    just for the first but it doesn't work. It happens nothing, every cell keep the background colour white.

    Any suggestion?

    Thanks a lot.

    Tuesday, July 02, 2013 5:07 PM

Answers

  • Just adding to ReportCreator's answer upon having the row numbers, you can then assign the colors by following code to the BackGroundColor property of the column  -

    =IIF(Fields!row_order.Value = 1,"#D4A017",IIF(Fields!row_order.Value = 2,"Silver",IIf(Fields!row_order.Value=3,"#8C7853","Black")))

    Note the values #D4A017 and #8C7853 refers to Gold and Bronze respectively.


    Regards,
    Karthik

    Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread.



    Wednesday, July 03, 2013 6:54 AM
  • Firstly you'd use an IIF rather than a switch here because the switch you have doesnt make sense.

    But next, how are you going to decide whats second and third??

    I suggest changing your query to return another column, like rownumber, so that you can know which 1,2 and 3 are

    Something like

    select top 10 amount, ROW_NUMBER() over(order by amount desc) as row_order from table_name

    Wednesday, July 03, 2013 3:22 AM

All replies

  • Firstly you'd use an IIF rather than a switch here because the switch you have doesnt make sense.

    But next, how are you going to decide whats second and third??

    I suggest changing your query to return another column, like rownumber, so that you can know which 1,2 and 3 are

    Something like

    select top 10 amount, ROW_NUMBER() over(order by amount desc) as row_order from table_name

    Wednesday, July 03, 2013 3:22 AM
  • Just adding to ReportCreator's answer upon having the row numbers, you can then assign the colors by following code to the BackGroundColor property of the column  -

    =IIF(Fields!row_order.Value = 1,"#D4A017",IIF(Fields!row_order.Value = 2,"Silver",IIf(Fields!row_order.Value=3,"#8C7853","Black")))

    Note the values #D4A017 and #8C7853 refers to Gold and Bronze respectively.


    Regards,
    Karthik

    Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread.



    Wednesday, July 03, 2013 6:54 AM
  • Gosh...error...

    Contains an error:
    [BC30452] OPERATOR '+' is not defined for types 'object' and 'Microsoft.ReportingServices.ReportProcessing.ReportobjectModel.Feild

    =IIF(Fields!RBAC.Value =1,"#D4A017",IIF(Fields!RBAC.Value =2,"Silver",IIf(Fields!RBAC=3,"#8C7853","Black")))

    I setted a field rank over ( order by bac) as rbac..everything ok but expression backcolour

    Thursday, July 04, 2013 3:42 PM
  • Mmm...I can understand, if I put:

    =IIF(Fields!RBAC.Value =1,"#D4A017",IIF(Fields!RBAC.Value =2,"Silver","Black")) it works but if I put one more condition =IIF(Fields!RBAC.Value =1,"#D4A017",IIF(Fields!RBAC.Value =2,"Silver",IIf(Fields!RBAC=3,"#8C7853","Black")))

    it returns 

    [BC30452] OPERATOR '+' is not defined for types 'object' and 'Microsoft.ReportingServices.ReportProcessing.ReportobjectModel.Feild

    Thursday, July 04, 2013 4:31 PM
  • You have forgot to put '.Value' in your expression. Please check with this expression -

    =IIF(Fields!RBAC.Value =1,"#D4A017",IIF(Fields!RBAC.Value =2,"Silver",IIf(Fields!RBAC.Value=3,"#8C7853","Black")))
    Note-I corrected my earlier post where I had missed '.Value'


    Regards,
    Karthik

    Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread.


    • Edited by V Karthik Friday, July 05, 2013 9:34 AM adding edit
    Friday, July 05, 2013 5:58 AM
  • IIF(RowNumber("TableName") = 1, "YELLOW", "GREEN")

    Friday, July 05, 2013 8:56 AM