3 Replies Latest reply on Oct 4, 2010 1:44 AM by LaRetta_1

    Text Formatting

    SamanthaB

      Title

      Text Formatting

      Post

      Hello,

      I have been racking my brain, basically i would like the result of a calculation to be a certain text colour.

      The calculation simply works out how many days between two dates...

      Deadline - Get(CurrentDate)

      What I would like it to do is colour the result green if over 5 days, orange between 2 and 5 days and red if 2 or under including negatives.

      Would much appreciate it if someone could push me in the right direction.

      Thanks

      Samantha

        • 1. Re: Text Formatting
          sunmoonstar.13

          Look up "conditional formatting" in FMP Help.

           

          Nick

           

          • 2. Re: Text Formatting
            Belton

            My take on it would use the Let function, Case function and TextColour function. (You don't need the Let but I think it makes things easier to read.) It would need to be unstored in order to recalculate each day.

            Let (  var.daysTodeadline = deadline - Get(CurrentDate)   ;

              Case ( var.daysTodeadline  > 5 ;          TextColor ( var.daysTodeadline ; RGB ( 0 ; 255 ; 0 ) ) ;            //green
                        2 < var.daysTodeadline  and  var.daysTodeadline ≤  5 ;  TextColor ( var.daysTodeadline ; RGB ( 255 ; 128 ; 0 ) ) ;        //orange
                                                                       TextColor ( var.daysTodeadline ; RGB ( 255 ; 0 ; 0 ) )             // red

             ) )

            you might want to think about the orange colour, it looks very much like red.

            --edit--

            for conditional formatting you'd break it down into three conditions (daysTodeadline being the name of the calculation field "deadline - Get(CurrentDate)" )

            daysTodeadline  > 5  // apply green formatting

            2 < daysTodeadline   and  var.daysTodeadline ≤  5 // apply orange formatting

            daysTodeadline   ≤  2 // apply red formatting

            You can more easily set up formats using conditional formatting and apply it to much more than just a single calculation result. You could colour a headline or change background colours as well. However it gets a little more fiddly setting it to several fields on several layouts.

            --another edit-- changed formula

            not sure why "2 < daysTodeadline  ≤  5" doesn't evaluate the same as "2 < daysTodeadline and  var.daysTodeadline ≤  5"

            ....probably because 2 is always less than 5 and my maths skills are weaker than I'd like !

            • 3. Re: Text Formatting
              LaRetta_1

              Belton suggested, "(daysTodeadline being the name of the calculation field "deadline - Get(CurrentDate)" )"

              No need for calculation at all - eliminate this field unless it is really needed somewhere else that can't be handled via conditional format or layout-level variables.

              "green if over 5 days, orange between 2 and 5 days and red if 2 or under including negatives."

              You have included 2 in two conditions (see portion I bolded in sentence above).  Anyway, you can adjust as needed.  Without knowing your FM version, we cannot truly say what you should do.  If you use conditional formatting, only two calculations are needed:

              Create first condition as:  "Value is" and "Less than x days ahead" and specify 5.  Make the text orange.
              Create second condition as:  "Value is" and "Less than x days ahead" and specify 3.  Make the text red.
              Make the regular text color of the field green.