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

11 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • 2 yrs ago
    • Reported - view

    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

      • Admin.11
      • 2 yrs 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?

      • Ninox partner
      • RoSoft_Steven.1
      • 2 yrs ago
      • Reported - view

      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

      • Admin.11
      • 2 yrs 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

      • Ninox partner
      • RoSoft_Steven.1
      • 2 yrs ago
      • Reported - view

      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

      • Admin.11
      • 1 yr 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 

    • Fred
    • 1 yr 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.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 1 yr 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)

      • Fred
      • 1 yr 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.

      • Ninox partner
      • RoSoft_Steven.1
      • 1 yr ago
      • Reported - view

      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...

    • Mel_Charles
    • 1 yr ago
    • Reported - view

    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......

     

     

Content aside

  • 1 yr agoLast active
  • 11Replies
  • 379Views
  • 5 Following