Skip to main content
February 16, 2024
Question

Calculation and Colour Logic.

  • February 16, 2024
  • 3 replies
  • 0 views

Hi , I am stuck with some logic here in color code, I need to represent variance column in amber colour ,if the varience is dropped to 50%. than actual value, Now this variance column is calculated with formula (actual-cov.threshold)/actual*100 so getting value is.How would I calculate that?I have used richtextDisplayfield

 a!richTextDisplayField(
              value: a!richTextItem(
                text: fv!item.varience_txt,
                color: if(
                  fv!item.varience_txt < 0,
                  "NEGATIVE",
                  if(
                    fv!item.varience_txt > 0,
                    "POSITIVE",
                    if(
                      (fv!item.varience_txt) < (fv!item.actualThreshold_txt * 0.5),
                      "#FFBF00",
                      ""
                    )
                  )
                )
              )
            )
  

    3 replies

    stefanhelzle0001
    Brainy
    February 16, 2024

    Not sure what your question is...

    But, maybe the issue is that it seems like you store a numerical value as text. Now, trying to compare a text to a number will not really work all the time.

    harshitb6843
    February 16, 2024

    Please don't use nested if() use a!match() instead. Nested if() are not performant. 

    To answer your question, what you are doing is correct. The reason why you can't see it could be that

    1. There is no value that matches with the condition (as seen in the screenshot also)
    2. Type mismatch between operands. 
    February 16, 2024

    ok thanks for your suggestion.