Forum Discussion

AlexBennett3's avatar
AlexBennett3
Qrew Trainee
5 years ago

Formula Change from Decimal to Percentage

Hey Everyone,

This is a Rich Text field.

I'm working on a formula that takes a field and adds some styling to try and make the field larger while being highlighted based on its value. I've been able to get the result highlighted as wanted for display purposes, but my percentage field reverts back to decimal on display, is there something I can add to change this back to percentage? 

var number margin = [Total Job Gross Margin F];
If( $margin >= 0 , "<span style=\"background-color:#fbff00; font-size:16px; font-weight:bold\">"&$margin&"</span>", "<span style=\"background-color:#ff0000; font-weight:bold\">"&$margin&"</span>" )

The result is being highlighted but in decimal: 0.2813488
But it should be: 28.13%

Any recommendations on what I can add to the code to revert this back to decimal? ([Total Job Gross Margin F] value is 28.13%)

Thanks,
Alex

------------------------------
Alex Bennett
------------------------------
  • AustinK's avatar
    AustinK
    Qrew Commander
    A simple way would be just doing [Decimal Field] * 100. That would get you back to the percentage you are wanting and then just make sure the field only shows 2 decimal places. Not sure if that would work for all your data but I think it should. Definitely test it.
    • AlexBennett3's avatar
      AlexBennett3
      Qrew Trainee
      When I try to * 100 the result is just 0.

      ------------------------------
      Alex Bennett
      ------------------------------
      • AustinK's avatar
        AustinK
        Qrew Commander
        Where you are trying to do this? Is this in a new field that takes the completed decimal and then multiplies it by 100? Or are you adding this to a formula somewhere? If adding to a formula please post the formula.