This is a public Forum  publicRSS

Forum post

    Jebber
    Script to change color of one field based on condition of...
    Forum post posted June 14, 2010 by Jebber, last edited February 9, 2012
    1521 Views, 7 Comments
    Title:
    Script to change color of one field based on condition of another field
    Post:

    I am looking for a script / method of changing the color of a field based on the value in another field. How do you do that?

     

    Example; IF Field:customer = AMAT, then Field:action = the fill color red

     

    I would really appreciate the help here.

    Answer

     

    • Steve Wright
      posted June 14, 2010 by Steve Wright  Permalink

      Right click on the field you wish to format, then choose Conditional Formatting.

       

      You can then set up formula's such as  Field::Customer = "AMAT"  

      Then specify the colour options etc if that is true.

       

      If you wanted to apply conditional formatting using the same calculations to other fields etc, select them all first, then right click and choose conditional formatting.  This will apply the formatting to everything selected.

       

    • Jebber
      posted June 14, 2010 by Jebber  Permalink

      Thanks for the assistance.

       

      But I think I have the format wrong. What is the proper format to put in the Formula Is area?

       

      I keep getting a return saying that it cannot find my field.

       

      The condition field is "Top 30 Customer Type"

      The resulting field that I would like to change the color in is "Color Block"

       

       

    • Steve Wright
      posted June 14, 2010 by Steve Wright  Permalink

      You would apply the conditional formatting to the "Color Block" field

       

      Forumula is :

       

      Top 30 Customer Type = "AMAT"

       

      You may need to prefix the field name with the table name, but if you click specify you can select the field from the available list and it will format it correctly for you  i.e

       

      CustomerTypes::Top 30 Customer Type = "AMAT"

       

       

    • luis
      posted July 13, 2010 by luis  Permalink

      Is there a way to change the fill color without using conditional formatting? I'd like to do this because conditional formatting is not available in instant web publishing.

    • PhilModJunk
      posted July 15, 2010 by PhilModJunk  Permalink

      Create two calculation fields: If ( conditionalExpression ; FieldName ; "" )

      Format each with a different color, stack them on top of each other with a transparent fill color and use conditional expressions that will always leave one field blank and the other displaying data. (That's how we did this in older versions without conditional formatting. Don't see why it wouldn't work with IWP.)

    • luis
      posted July 15, 2010 by luis  Permalink

      Thanks Phil

      Unless I am missing something, the transparent fill pattern implies no fill color, so the approach you suggest does not seem to work for my purposes. However, it does allow me to use indentation rather than background color to convey the difference between my data, which seems good enough :)

      thanks again,

    • PhilModJunk
      posted July 15, 2010 by PhilModJunk  Permalink

      Good point as I was thinking in terms of changing the text color rather than the fill color. To do that you can set up a calculation that returns a container type. It can return the contents of a container field that has a red rectangle in it to show a red "fill color" and it can return the contents of a container field with a blue rectangle to show a blue "fill color"...

      Now put this field behind your transparent data field to show a "fill color" change.