Conditionally change color based on number value of another column

Occasional Contributor



I have two number columns - "Staff" and "Capacity". I would like the "Capacity" column to conditionally display red if the number on the "Staff" column is 10 less than the number on the "Capacity" column. 


For example if "Staff" equals 86 and "Capacity" equals 96, then either the row or the cell on the "Capacity" column should display as red. 


I've looked at the basic column formatting but it doesn't appear to have a function to compare between the both.



1 Reply

@Chris Cundy I think you are looking something like this:


To achieve this you can use the below code:

   "$schema": "",
   "elmType": "div",
   "txtContent": "@currentField",
   "style": {
      "background-color": "=if([$Staff]<10, '#FFA07A', '')"

Hopefully this should help. Provide appropriate response if it helps to reach your solution.