1

I need to do a databar format on a choice column with text inside. Is this possible? I can get it easily enough with the given JSON formatting code but i cannot seem edit the code below enough to where it gives me why I need. My choice are New, Approved, Scoping, and Completed.

{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "children": [ { "elmType": "span", "txtContent": "@currentField", "style": { "padding-left": "8px", "white-space": "nowrap" } } ], "attributes": { "class": "sp-field-dataBars" }, "style": { "padding": "0", "width": "=if(@currentField >= 20, '100%', (@currentField * 5) + '%')" } }

2

Would this one help you?

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "children": [
    {
      "elmType": "span",
      "txtContent": "@currentField",
      "style": {
        "padding-left": "8px",
        "white-space": "nowrap"
      }
    }
  ],
  "attributes": {
    "class": "sp-field-dataBars"
  },
  "style": {
    "padding": "0",
    "width": "=if(@currentField == 'New', '25%', if(@currentField == 'Approved', '50%',if(@currentField == 'Scoping', '75%','100%')))",
    "box-sizing": "border-box"
  }
}
| improve this answer | |
  • Ah, thats why all the crap i tried didnt work. I was nesting the ifs differently. I spent way too long on this last night. thank you. – Klj126 Oct 29 '19 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.