0

Colour Coding

Hi There,

I have a formulae field that sums the number of guests in a subtable.

I would now like it to be green if the formaulae field number is smaller then "Max Pax" and red if larger

I have used the style code but i keep getting end expected and can't seem to have more then one coding in the same area i.e if function then style function

11replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • There are several methods to achieve this, this is one of those:

    let S := sum(Guests.GuestsPresent);
    if S > 'Max Pax' then
        styled(text(S), "red")
    else
        styled(text(S), "green")
    end
    

    Steven

    Like
      • Admin
      • Admin.11
      • 8 mths ago
      • Reported - view

      RoSoft_Steven Rooryck 

      Thanks Steven that would perfectly, However, next problem,

      IT has turn the field into a text field.

      I have another field that sums all pax.

      Now that i got the colour working, it doenst count the field as i believe it is now a text field.

      Im getting Invalid operator: number on one field and the other doesn't include the number in the field.

      thoughts?

      Like
    • Admin you can eighter use let S := sum(Guests.Guestspresent) and use the variable S for the calculation or second option is to convert the first formula field to a number again : number(text(formulafield1)) 

      Steven

      Like
      • Admin
      • Admin.11
      • 8 mths ago
      • Reported - view

      RoSoft_Steven Rooryck 

      Im not entirely sure what you mean on the code number(text(formulafield1)) im assuming formula filed 1 is the field that is txt field now not a number.

      Ive got a table where the customer books how many adults and how many kids they have in their group. There is a formulae field at the top call '10am Snorkelers' which sums all the adults and all the kids and gives the total amount. 

      the following formulae is what is written and works:

      sum('Snorkelers 10am'.Adults) + sum('Snorkelers 10am'.'Kids (Under 12)')

      I have another field which is a number field which is '10 am Max Snorkelers'.

      This is manually inputted by the staff so set the maximum guests we can have on that particular tour.

      I now use the following code in hopes that if the total number of snorkelers is larger then the max field then it will be red and green if it is under:

      let t:=sum('Snorkelers 10am'.Adults) + sum('Snorkelers 10am'.'Kids (Under 12)')

      if t > '10 am Max Snorkelers' then
       styled(text(S), "red")
      else
          styled(text(S), "green")
      end

      This unfortunatly does not seem to work.

      Hope this makes it clearer

      Like
    • Admin Yes, You're right, I'm converting the formula field again to a number.

      number(text('10am Snorkelers')) should give you the number value of this field.

      Your second code is also not right, it should be:

      let t:=sum('Snorkelers 10am'.Adults) + sum('Snorkelers 10am'.'Kids (Under 12)')
      if t > '10 am Max Snorkelers' then
       styled(text(t), "red")
      else
          styled(text(t), "green")
      end
      

      Let us know how it goes, don't hesitate to ask if you need more help.

      Steven

      Like
      • Admin
      • Admin.11
      • 6 mths ago
      • Reported - view

      RoSoft_Steven I did end up finding a soloution:

      let t := '10am Max Snorkelers' - '10 am Snorkelers Booked';
      if t < 1 then
          styled(text(t), "red")
      else
          styled(text(t), "green")
      end

       

      ended up creating another formulae field that added the total number of snorkelers 

      Like
    • Fred
    • Fred
    • 6 mths ago
    • Reported - view

    Have you looked into Conditional Styling for columns? This is helpful if you only want to see it in a table view.

    In a table view or view element, if you click on the column name you will see the Conditional Styling text. If you click on that you will see a blank Conditional Styling window. Click on Add Rule and then put in rules for how you want the cells formatted.

    Like
      • Rafael
      • Rafael Sanchis
      • Rafael_Sanchis
      • 6 mths ago
      • Reported - view

      Fred 

      I use these formula for calculation CPI_Project, but is posible change the color text only 

      let t := Earned_Value / Total_Cost;
      if t < 1 then
          styled(text(t), "red")
      else
          styled(text(t), "green")
      end

      But the following formula give me error for calculation EAC.

      Total_Budget / (CPI_Project * SPI_Project)

      Like
      • Fred
      • Fred
      • 6 mths ago
      • Reported - view

      I don't use styled very much so I don't know if it can do text on its own. I think I saw somewhere about using HTML to color text, but I can't say for sure.

      Like
    • Rafael 

      As in the manual the styled function accept more than one setting: 

      styled(myText, backgroundColor, fontColor, icon)

      so in your case you can use styled(text(t),"","blue") for example.

      and of cource the html styling is also usable...

      Like
  • Okay I have a slightly different take on this:-

    I have some number fields that I want to say as number and indeed some text fields that I want to be styled (Highlighted in some way) but don't want to convert the underlying values.

    This is mainly for a partially sighted member of staff that helps with some data entry that

    So for this staff member I have a duplicate form (but I am showing you a cut down sample version here)

    So in this simple sample i have 2 fields - qty and desc

    I added next to each of them 2 formula fields fxQty and fxDesc (which both can by styled and set to bigger font etc) and both point to the prev two fields.

    At the top of the form I have an Edit Form? yes/no field (this is set to true on form creation)

    the Qty and Desc fields display if - is set to when "Edit form?" is true and the fxQty and fxDesc formula fields display if - is set to when "Edit form?" is false

    The save button only displays when in edit mode and itself turns of the edit form? flag

    at the bottom of the form there is button to update and copy the whole form into the main table but thats another story......

     

     

    Like
Like Follow
  • 6 mths agoLast active
  • 11Replies
  • 177Views
  • 5 Following