Conditional Formatting

Hi,

I need to apply conditional formatting based on another row in the sheet. Higher it should be highlighted in red, equal to or below highlighted in green.

It would be easy to just use the target figures in the conditional formatting rules but I need to be able to change it frequently without changing all the formatting rules...

Can this be done?

Thanks

Best Answer

  • Carson Penticuff
    Carson Penticuff ✭✭✭✭✭✭
    Answer ✓

    @isabonita is on the right track. This is kind of an involved answer, but once you figure out the logic, it isn't that bad.

    You cannot reference specific cells in the conditional format in a manner that would make this easy. You cannot, for instance, say IF this specific cell is greater than that cell, apply this format. You can do it for the same row, but not always referencing the same cell. We get around this by inserting a "helper" column for each condition we want to check. The checkbox format works great. In the conditional format rule, you can simply say IF THIS cell is checked, apply the format to THAT cell.

    To set the checkbox to checked/unchecked, we use this column formula: =IF(PDP@row > PDP#, 1, 0)

    But what is PDP#? This is another issue we have to work around. You cannot reference the first cell of a column in a column formula, you can only reference cells in the same row. To work around this, we add fields into the sheet summary. [PDP]# references the PDP field in the sheet summary. In order to make updating these values easier, we set the value of this field equal to the first cell in the PDP column using =PDP1

    After creating all of the helper columns, setting up the column formulas for each to determine which ones are checked, creating all of the necessary fields in the sheet summary, and setting those equal to the first cells in each of the respective columns within the sheet, we can set up the conditional formatting.

    Check out the image below to get an idea of how to setup the formats. Unfortunately, we have one more workaround to setup at this stage. Since the formatting will apply to every row in the sheet, it will apply to the first row as well and all of those cells will be green. To get around this, add the first format pictured below as the first one in your list. For the background color, you must select "white" in order to avoid the highlight. If you set it to "no background", you will get an error because Smartsheet does not see "no background" as a format.

    After everything is setup and running, you should be able to update the cells in your target row and things will work themselves out automatically.



    I hope this helps, and I really hope it makes sense.

Answers

  • isabonita
    isabonita ✭✭✭

    I would do something like this with a Helper column with a formula that would do the calculation I need.

    IF ([CBP2]@row > [CBP2]1, "red", "green")

    Is it always going to compare to the TARGET row? then just use [CBP2]$1 (or whatever that row number is)

    Then have the conditional formatting look at the correct column and only color that column (and not the entire row) with the formatting

    You would need to create a helper for each column - this would be one place I wouldn't be able to use a column formula. You would drag the formula through the sheet.

    There are probably some better ways to handle this - so I look forward to hearing what others think!

  • Carson Penticuff
    Carson Penticuff ✭✭✭✭✭✭
    Answer ✓

    @isabonita is on the right track. This is kind of an involved answer, but once you figure out the logic, it isn't that bad.

    You cannot reference specific cells in the conditional format in a manner that would make this easy. You cannot, for instance, say IF this specific cell is greater than that cell, apply this format. You can do it for the same row, but not always referencing the same cell. We get around this by inserting a "helper" column for each condition we want to check. The checkbox format works great. In the conditional format rule, you can simply say IF THIS cell is checked, apply the format to THAT cell.

    To set the checkbox to checked/unchecked, we use this column formula: =IF(PDP@row > PDP#, 1, 0)

    But what is PDP#? This is another issue we have to work around. You cannot reference the first cell of a column in a column formula, you can only reference cells in the same row. To work around this, we add fields into the sheet summary. [PDP]# references the PDP field in the sheet summary. In order to make updating these values easier, we set the value of this field equal to the first cell in the PDP column using =PDP1

    After creating all of the helper columns, setting up the column formulas for each to determine which ones are checked, creating all of the necessary fields in the sheet summary, and setting those equal to the first cells in each of the respective columns within the sheet, we can set up the conditional formatting.

    Check out the image below to get an idea of how to setup the formats. Unfortunately, we have one more workaround to setup at this stage. Since the formatting will apply to every row in the sheet, it will apply to the first row as well and all of those cells will be green. To get around this, add the first format pictured below as the first one in your list. For the background color, you must select "white" in order to avoid the highlight. If you set it to "no background", you will get an error because Smartsheet does not see "no background" as a format.

    After everything is setup and running, you should be able to update the cells in your target row and things will work themselves out automatically.



    I hope this helps, and I really hope it makes sense.

  • isabonita
    isabonita ✭✭✭

    @Carson Penticuff - yes! Sheet Summary fields! Much better...

  • WillH
    WillH ✭✭✭

    Thank you @isabonita & @Carson Penticuff, worked a treat! 😁