SOLVED

SharePoint List - Highlight a cell based on status of a different cell

%3CLINGO-SUB%20id%3D%22lingo-sub-2098142%22%20slang%3D%22en-US%22%3ESharePoint%20List%20-%20Highlight%20a%20cell%20based%20on%20status%20of%20a%20different%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2098142%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20there%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20like%20to%20format%20some%20date%20cells%20on%20a%20SharePoint%20List%20so%20they%20are%20highlighted%20a%20different%20colour%20if%20the%20corresponding%20cell%20on%20the%20adjacent%20column%20has%20'Confirmed'%20entered.%20I've%20added%20a%20mock%20up%20of%20how%20it%20would%20look%20ideally%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Laurie88_0-1611674062888.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F249514i4D65BDB8A39A3995%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Laurie88_0-1611674062888.png%22%20alt%3D%22Laurie88_0-1611674062888.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EBasically%20we%20need%20to%20have%20a%20quick%20view%20of%20the%20status%20of%20the%20date%20through%20formatting.%20I'd%20like%20to%20hide%20the%20condition%20column%20as%20there%20will%20be%20quite%20a%20few%20of%20them%20(mulitiple%20date%20columns).%20I%20can%20then%20manually%20choose%20if%20a%20date%20is%20provisional%20or%20confirmed%20and%20other%20users%20will%20be%20able%20to%20see%20the%20status%20of%20the%20date%20only%20from%20the%20date%20cell.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20help%20would%20be%20really%20appreciated!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2098142%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2098356%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20List%20-%20Highlight%20a%20cell%20based%20on%20status%20of%20a%20different%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2098356%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F943178%22%20target%3D%22_blank%22%3E%40Laurie88%3C%2FA%3E%26nbsp%3BYou%20can't%20do%20that%20using%20the%20Format%20Column%20through%20the%20UI%2C%20but%20you%20can%20do%20it%20with%20a%20little%20bit%20of%20JSON%20based%20conditional%20formatting.%20The%20following%20should%20do%20what%20you%20need%20and%20just%20get's%20pasted%20into%20the%20Format%20area%20of%20the%20Column%20settings.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20only%20downside%20is%20that%20the%20field%20you%20trigger%20on%20must%20be%20in%20the%20view.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EJust%20change%20the%20colours%20to%20suite%20by%20replacing%20Blue%2FRed%20with%20a%20hashcode%20like%20%23ec3c35%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%7B%3CBR%20%2F%3E%22%24schema%22%3A%22%3CA%20href%3D%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fv2%2Fcolumn-formatting.schema.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fv2%2Fcolumn-formatting.schema.json%3C%2FA%3E%22%2C%3CBR%20%2F%3E%22elmType%22%3A%22div%22%2C%3CBR%20%2F%3E%22txtContent%22%3A%22%40currentField%22%2C%3CBR%20%2F%3E%22style%22%3A%7B%3CBR%20%2F%3E%22background-color%22%3A%20%22%3Dif(%5B%24Condition%5D%20%3D%3D%20'Confirmed'%2C'blue'%2C'red')%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPaul.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2098382%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20List%20-%20Highlight%20a%20cell%20based%20on%20status%20of%20a%20different%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2098382%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F943178%22%20target%3D%22_blank%22%3E%40Laurie88%3C%2FA%3E%26nbsp%3Bvery%20straightforward%20with%20JSON%20column%20formattingClick%20on%20the%20NJ%20Launch%20dropdown%20%26gt%3B%20column%20settings%20%26gt%3Bformat%20this%20column%2C%20then%20click%20on%20the%20advanced%20mode%20link%20and%20add%20the%20following%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%22%24schema%22%3A%20%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fcolumn-formatting.schema.json%22%2C%0A%22elmType%22%3A%20%22div%22%2C%0A%22txtContent%22%3A%20%22%40currentField%22%2C%0A%22style%22%3A%20%7B%0A%22padding-left%22%3A%20%2214px%22%2C%0A%22background-color%22%3A%20%22%3Dif(%5B%24Condition%5D%20%3D%3D%20'Confirmed'%2C'%2300c36f'%2C%20(if(%5B%24Condition%5D%20%3D%3D%20'Provisional'%2C'%23ff7e00'%2C%20'%23d0d0d0')))%22%2C%0A%22color%22%3A%20%22white%22%0A%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20the%20result%20looks%20like%20this%20and%20you%20can%20then%20hide%20the%20Condition%20column%3A%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22multiIFs.png%22%20style%3D%22width%3A%20270px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F249558iFE462FF08A31706E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22multiIFs.png%22%20alt%3D%22multiIFs.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERob%3CBR%20%2F%3ELos%20Gallardos%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23006400%22%3EMicrosoft%20Power%20Automate%20Community%20Super%20User%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2101880%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20List%20-%20Highlight%20a%20cell%20based%20on%20status%20of%20a%20different%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2101880%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F174092%22%20target%3D%22_blank%22%3E%40Rob%20Elliott%3C%2FA%3E%26nbsp%3BThat%20works%20perfectly.%20Thank%20you%20so%20much!%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi there,

 

I would like to format some date cells on a SharePoint List so they are highlighted a different colour if the corresponding cell on the adjacent column has 'Confirmed' entered. I've added a mock up of how it would look ideally:

Laurie88_0-1611674062888.png

Basically we need to have a quick view of the status of the date through formatting. I'd like to hide the condition column as there will be quite a few of them (mulitiple date columns). I can then manually choose if a date is provisional or confirmed and other users will be able to see the status of the date only from the date cell.

 

Any help would be really appreciated!

4 Replies

@Laurie88 You can't do that using the Format Column through the UI, but you can do it with a little bit of JSON based conditional formatting. The following should do what you need and just get's pasted into the Format area of the Column settings.

 

The only downside is that the field you trigger on must be in the view.

 

Just change the colours to suite by replacing Blue/Red with a hashcode like #ec3c35

 

{
"$schema":"https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType":"div",
"txtContent":"@currentField",
"style":{
"background-color": "=if([$Condition] == 'Confirmed','blue','red')"
}
}

 

You'll need to do this for each Date column and vary the trigger column name ($Condition) to match. Note if you have spaces in your column names, it'll look like $Condition_X0020_Column 

 

More details on this approach here: Use column formatting to customize SharePoint | Microsoft Docs

 

Paul.

Best Response confirmed by Juan Carlos González Martín (MVP)
Solution

@Laurie88 very straightforward with JSON column formattingClick on the NJ Launch dropdown > column settings >format this column, then click on the advanced mode link and add the following:

 

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"padding-left": "14px",
"background-color": "=if([$Condition] == 'Confirmed','#00c36f', (if([$Condition] == 'Provisional','#ff7e00', '#d0d0d0')))",
"color": "white"
}
}

 

 

and the result looks like this and you can then hide the Condition column:
multiIFs.png

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

@RobElliott That works perfectly. Thank you so much!