1

I have a column that is a Risk Index that calculates based on other columns. The equation calculates as following:

  • -50
  • 0
  • 30
  • 70
  • 100

-50 = Pending Review / 0 = Completed, no risk / 30 = Risk Mitigated / 70 = Working through Risks / 100 = OH NO FIRE FIRE FIRE

This is my JSON Formatting:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "padding": "10px"
  },
  "attributes": {
    "class": "=if(@currentField < '0', 'sp-field-severity--low',if(@currentField < '20', 'sp-field-severity--good', if(@currentField < '40', 'ms-bgColor-themeLighter', if(@currentField <= '70', 'sp-field-severity--warning', 'sp-field-severity--blocked'))) + ' ms-fontColor-neutralPrimary'"
  },
  "customCardProps": {
    "openOnEvent": "hover",
    "directionalHint": "rightCenter",
    "isBreakVisible": false,
    "formatter": {
      "elmType": "div",
      "style": {
        "font-size": "12px",
        "display": "block",
        "margin-left": "auto",
        "margin-right": "auto",
        "width": "180px",
        "padding": "4px"
      },
      "txtContent": "[$Overall_x0020_Risk_x0020_Summary]"
    }
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 6px"
      },
      "attributes": {
        "iconName": "=if(@currentField < '0', 'HourGlass',if(@currentField < '20', 'CheckMark', if(@currentField < '40', 'MultiSelect', if(@currentField <= '70', 'WarningSolid', 'WarningSolid')))"
      }
    },
    {
      "elmType": "span",
      "txtContent": "=if(@currentField < '0', 'Incomplete',if(@currentField < '20', 'No Risk', if(@currentField < '40', 'Risk Acceptable', if(@currentField <= '70', 'Med. Risk', 'Attention Required',)))"
    }
  ]
}

It was working fine until today, when suddenly, anything ranking at 100 is showing as "No Risk"... calculation is working fine, it is definitely rated at 100 but it is being formatted as if it was 0.

I checked with colleagues, and it seems only MY computer seems to be the issue. I've reset my views, I cleared my cache, tried FireFox and Edge but for whatever reason, it's still formatting incorrectly only for me. Perhaps for others as well. What's going on?

WITH FORMATTING:

with formatting

WITHOUT FORMATTING

without formatting

4
  • Could you edit your question and paste a screenshot of the column without the format and a screenshot with the format? Thanks! Commented Apr 21, 2022 at 12:52
  • I can see few syntax errors like: one ) is missing in expressions for class, iconName, txtContent, etc. Also, there is one extra , at the end of last if block in expression for txtContent property. Commented Apr 21, 2022 at 16:30
  • @theChrisKent - done! But now that I've done it, I've asked colleagues to send me screenshots as well - the formatting works for them perfectly. Not for me, and not for meaccross chrome / firefox / edge...even after clearing cookies. Commented Apr 22, 2022 at 9:59
  • Try converting the field using the Number() function in your conditional expressions and use numbers instead of strings. (e.g: if(Number(@currentField) < 0, 'sp-field-severity--low...') Commented Apr 28, 2022 at 13:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.