Color change based on a number

Hi @Mike_Driscoll :blush: !

If your formula is on the canvas, you could use Format() and while storing the needed templates “elsewhere” (in a table, for example) apply the desired color on the placeholder Format() uses to do what it needs to do which should then be applied on the value when Format() runs :blush: .

Here’s a very very very quick sample (down below :innocent: ) where I’ve created 3 templates Format() should use depending on the value of the canvas slider :blush:
All the rows containing the needed templates have been @ref (e.g.: @Negative.Template)

The canvas formula looks like this :

Format(
  // Template to use depending on the value of [slider 1]
  SwitchIf(
    [slider 1] < 0,
    Negative.Template,
    [slider 1] = 0,
    Zero.Template,
    [slider 1] > 0,
    Postive.Template
  ),
  // the value the placeholder {1} should take
  [slider 1]
)

And I guess your formula should replace the [slider 1] I used :blush:

To avoid having to recalculate your Round() formula too many times, you could store its value using WithName() so the formula should become something like:

// Store the value returned by Round( ... ) within RoundOutput
Round( ... ).WithName(RoundOutput,
    Format(
      // Template to use depending on the value of RoundOutput
      SwitchIf(
        RoundOutput < 0,
        Negative.Template,
        RoundOutput = 0,
        Zero.Template,
        RoundOutput > 0,
        Positive.Template
      ),
    // the value the placeholder {1} should take
    RoundOutput
  )
)

Now, if it’s in table, you could apply some conditional formatting instead :blush:

I hope this helps a little :innocent:

1 Like