0

Styled number field maintaining it numerical?

I know we can use this:

styled(text, colour, icon)

To change the background and icon for a given field.

 

The problem comes when you have a calculation, say “TOTAL”, which is a NUMBER (to be combined with “if” to create conditional styles, like using red background for negative numbers, green for positive…)

On these cases we should use a:

styled(text(TOTAL), colour, icon)

 

But then, this field becomes a TEXT, no more a NUMBER and consequently we can not use math-filtering, like sum, average, minimum, maximum…

 

It's possible to add a style to a numerical calculation field and maintain it like a NUMBER?

 

Thanks for your support!

10 replies

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

    Better use a second field for that, and let that remain a number. Like a phantom field or duplicate as you prefer. 
    you can hide this field if you want and only use the styled field visible on the forms.

    Steven

    • Etérea Estudios
    • Cristobal
    • 4 yrs ago
    • Reported - view

    Thanks for your reply, Steven! :-)

     

    Yeah, that could be a workaround just to see the styled field (green por positive / red for negative) in the FORM and a second version as a number in the table.

     

    The problem comes if you want to see that styled field also on the table view AND to be able to execute math-filtering (sum, average…) on that column.

     

    Not a great problem. I'm extremely happy with my transition from FileMaker to Ninox. I suppose is just a question of time for this kind of features (styled numbers and others) to appear in Ninox in future releases :-)

     

    Cristóbal

      • Database App Developer
      • vermau81
      • 2 mths ago
      • Reported - view

       Hi, did you find a solution to this problem. I ran into same problem today. Styled() still does not support numeric parameters and once we convert them to text, they loose all numeric value.

      The problem that I am facing is that once I use style() on a "OrderTotal" formula field, it converts to styled() object. If I try to convert the result back to a number using the number() function, the formula fields displays nothing and becomes empty.

    • red_kite
    • 2 mths ago
    • Reported - view

    It is possible.

    let meNumber := 33;
    let meStyled := styled(text(meNumber), "firebrick", "white", formatJSON({
            weight: 200,
            filling: 1,
            icon: "travel_explore",
            color: "gold"
        }));
    number(parseJSON(formatJSON(meStyled)).text)
    

    1. build a JSON, 2. build an Object, 3. use the pointnotation for the first part named "text" , 4. convert to number

      • Rafael Sanchis
      • Rafael_Sanchis
      • 2 mths ago
      • Reported - view

       

      Hi MZ Strange, it doesn't work for me 😯

      • red_kite
      • 2 mths ago
      • Reported - view

       

      let meNumber := 33;
      let meStyled := styled(text(meNumber), "firebrick", "white", formatJSON({
              weight: 200,
              filling: 1,
              icon: "travel_explore",
              color: "gold"
          }));
      debugValueInfo(number(parseJSON(formatJSON(meStyled)).text))
      

      result

      number(33)
      

      Mirko

      • Sean
      • 2 mths ago
      • Reported - view

       Same for me. If I remove the number() function the style is applied, but the alignment is left. If I use the number() function as it is posted the style is removed and the alignment is right.

      • szormpas
      • 2 mths ago
      • Reported - view

           it works for me. See the screenshot.

      Formula_1:

      let meNumber := 33;
      let meStyled_1 := styled(text(meNumber), "firebrick", "white", formatJSON({
              weight: 200,
              filling: 1,
              icon: "travel_explore",
              color: "gold"
          }));
      meStyled_1
      

      Formula_2:

      let x := number(parseJSON(formatJSON(Formula_1)).text) * 2;
      let meStyled_2 := styled(text(x), "firebrick", "white", formatJSON({
              weight: 200,
              filling: 1,
              icon: "travel_explore",
              color: "gold"
          }));
      meStyled_2
      

       interesting solution, thanks!

      • Fred
      • 2 mths ago
      • Reported - view

      I don't think that is what the post is about. It asks to style a number while keeping it a number. Since the numbers are shown to be left aligned it has been turned into text.

      As we know once you styled() something it becomes text, or really it becomes any since it is put into a JSON (see this post for more info).

      • szormpas
      • 2 mths ago
      • Reported - view

        Fred, thank you, I was not aware of the existence of this post and it is something useful.
      About my example in formula_2, I first convert formula_1 to a number, do the multiplication and then apply styled() again. I mean, I wanted to show that the solution suggested by MZ can work in practice.

Content aside

  • 2 mths agoLast active
  • 10Replies
  • 1030Views
  • 6 Following