Back to column formats
Column formattingSharePoint 2019SharePoint Online

Conditional Progress Color

This sample demonstrates displaying progress bar with conditional color based on the value.

Conditional Progress Color formatting preview
Sample preview · View original image

Copy. Apply. Make it yours.

Get this format

1 definition

Review the requirements below, then paste this JSON into the matching formatting panel. Show me where.

Use your list's internal column names and replace any tenant-specific URLs or flow IDs. Formatting is presentation, not a way to secure data.

Column formatting
Download JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "children": [
    {
      "elmType": "div",
      "txtContent": "=(@currentField * 100) + '%'",
      "style": {
        "position": "absolute",
        "white-space": "nowrap",
        "padding": "0 4px"
      },
      "attributes": {
        "class": "=if(@currentField <= 0.3, 'ms-fontColor-alert', if(@currentField < 1, 'ms-fontColor-sharedOrange20', 'ms-fontColor-sharedGreenCyan10'))"
      }
    },
    {
      "elmType": "div",
      "attributes": {
        "class": "=if(@currentField <= 0.3, 'sp-css-backgroundColor-errorBackground40 sp-css-borderTop-errorBorder', if(@currentField < 1, 'sp-css-backgroundColor-warningBackground40 sp-css-borderTop-warningBorder', 'sp-css-backgroundColor-successBackground40 sp-css-borderTop-successBorder'))"
      },
      "style": {
        "width": "=(@currentField * 100) +'%'",
        "min-height": "inherit",
        "box-sizing": "border-box"
      }
    }
  ]
}

From the contributor

How to use this sample

Summary

This sample demonstrates displaying progress bar with conditional color based on the value.

  • Red for value <= 0.3 (30%)
  • Yellow for 0.3 (30%) < value < 1 (100%)
  • Green for value == 1 (100%)

screenshot of the sample

View requirements

  • This format can be applied to a Number column. It is expected that the values will be from 0 to 1 (percent)

Sample

Solution Author(s)
number-conditional-progress-color.json Ari Gunawan

Version history

Version Date Comments
1.0 October 9, 2021 Initial release

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.


Additional notes