Forum Discussion

alandarr's avatar
alandarr
Brass Contributor
Aug 03, 2020
Solved

List format question, with an either/or scenario

  1) I have a column that is set for numbers, shown as a percentage.   I'm trying to format the column where if I type into the field "100", it would color the field red and if I type "0", it woul...
  • RobElliott's avatar
    Aug 05, 2020

    alandarr just looking at your question 1 for the moment you can do this with the following JSON column formatting. In this example if the value you enter is less than or equal to 10% then it puts the background green, if it's between 11 and 50% then it's orange, otherwise it's dark red:

     

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "=toString(@currentField * 100) + '%'",
      "style": {
        "border": "none",
        "padding-left": "14px",
        "background-color": "=if(@currentField <= 0.1,'#468259', if(@currentField > 0.1 && @currentField <= 0.5,'#d8a810', '#c00000'))",
        "color": "white"
      }
    }

     

    Which gives the following result:

    I hope that gives you what you need.

     

    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User.
    If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.