SOLVED

Conditional formatting list field based on multiple field values

%3CLINGO-SUB%20id%3D%22lingo-sub-1293130%22%20slang%3D%22en-US%22%3EConditional%20formatting%20list%20field%20based%20on%20multiple%20field%20values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1293130%22%20slang%3D%22en-US%22%3E%3CP%3EHi!%3C%2FP%3E%3CP%3ECan%20I%20format%20a%20list%20field%20using%20a%20field%20extension%20based%20on%20a%20given%20logic%20from%20multiple%20fields%20on%20a%20row%3F%3CBR%20%2F%3ELet's%20assume%2C%20I%20have%20a%20list%20with%203%20columns%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CTABLE%20border%3D%221%22%20width%3D%22100%25%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%2233.333333333333336%25%22%3EEnddate%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%3EStatus%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%3E%3CSTRONG%3ETraffic%20light%3C%2FSTRONG%3E%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2233.333333333333336%25%22%3E1%2F4%2F2020%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%3EDone%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%3E%3CSTRONG%3EGreen%3C%2FSTRONG%3E%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2233.333333333333336%25%22%3E2%2F4%2F2020%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%3EOpen%3C%2FTD%3E%3CTD%20width%3D%2233.333333333333336%25%22%3E%3CSTRONG%3ERed%3C%2FSTRONG%3E%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20background%20color%20of%20field%20%22Traffic%20light%22%20should%20be%20either%20Green%20or%20Red%2C%20depending%20on%20the%20condition%3A%3C%2FP%3E%3CP%3Eif%20Enddate%20%26lt%3B%20Today%20and%20Status%20%3D%3D%20Done%20%3D%20Green%3C%2FP%3E%3CP%3Eif%20Enddate%20%26lt%3B%20Today%20and%20Status%26nbsp%3B%20%3D!%20Done%20%3D%20Red%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20that%20possible%20and%20are%20field%20extensions%20the%20right%20tool%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20very%20much.%3CBR%20%2F%3EFilipe%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1293130%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1296302%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20formatting%20list%20field%20based%20on%20multiple%20field%20values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1296302%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EYou%20can%20use%20column%20formatting%20to%20display%20the%20background%20color%20in%20your%20required%20field%20%5BConditional%20formatting%20based%20on%20the%20other%20field%20values%5D%20as%20per%20your%20requirement.%20You%20would%20need%20to%20construct%20a%20JSON%20object%20that%20describes%20the%20elements%20that%20are%20displayed%20when%20your%20field%20is%20included%20in%20a%20list%20view%20and%20their%20display%20style.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20refer%20to%20this%20sample%20which%20will%20be%20helpful%20for%20your%20current%20requirement%20-%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fdeclarative-customization%2Fcolumn-formatting%23apply-formatting-based-on-date-ranges%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fdeclarative-customization%2Fcolumn-formatting%23apply-formatting-based-on-date-ranges%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20are%20new%20to%20column%20formatting%2C%20please%20refer%20to%20this%20link%20which%20will%20help%20you%20to%20get%20started%20-%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fdeclarative-customization%2Fcolumn-formatting%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fdeclarative-customization%2Fcolumn-formatting%3C%2FA%3E.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F223877%22%20target%3D%22_blank%22%3E%40Filipe%20Matos%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20helps.%20Thanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1302554%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20formatting%20list%20field%20based%20on%20multiple%20field%20values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1302554%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F114813%22%20target%3D%22_blank%22%3E%40Swaminathan%20Sriram%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%2C%20your%20answer%20has%20pointed%20me%20in%20the%20right%20direction.%3C%2FP%3E%3CP%3EI%20was%20able%20to%20combine%20a%20calculated%20column%20with%20a%20column%20formatting%20to%20meet%20my%20purpose.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBest%20regards%3C%2FP%3E%3CP%3EFilipe%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1336323%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20formatting%20list%20field%20based%20on%20multiple%20field%20values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1336323%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F223877%22%20target%3D%22_blank%22%3E%40Filipe%20Matos%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20is%20actually%20an%20update%20rolling%20out%20globally%20that%20will%20help%20do%20this%20WITHOUT%20CODE!%20It%20landed%20in%20my%20tenant%20last%20week.%20Good%20luck%20-%20here%20is%20a%20link%20to%20the%20item%20in%20the%20road%20map.%20This%20link%20shows%20a%20lot%20of%20updates...but%20conditional%20formatting%20is%20the%20one%20I'm%20talking%20about.%20It's%20roadmap%20item%26nbsp%3B%3C%2FP%3E%3CUL%20class%3D%22c-list%20f-bare%20f-lean%20data-list%22%3E%3CLI%3EFeatured%20ID%3A%2057305%3C%2FLI%3E%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1339857%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20formatting%20list%20field%20based%20on%20multiple%20field%20values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1339857%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F28814%22%20target%3D%22_blank%22%3E%40Michael%20Malloy%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAwesome%2C%20just%20checked%20my%20tenant%20and%20found%20it%20too!%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20hint.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hi!

Can I format a list field using a field extension based on a given logic from multiple fields on a row?
Let's assume, I have a list with 3 columns:

 

EnddateStatusTraffic light
1/4/2020DoneGreen
2/4/2020OpenRed

 

The background color of field "Traffic light" should be either Green or Red, depending on the condition:

if Enddate < Today and Status == Done = Green

if Enddate < Today and Status  =! Done = Red

 

Is that possible and are field extensions the right tool?

 

Thank you very much.
Filipe

4 Replies
Highlighted
Best Response confirmed by Filipe Matos (Occasional Contributor)
Solution

Hi,

You can use column formatting to display the background color in your required field [Conditional formatting based on the other field values] as per your requirement. You would need to construct a JSON object that describes the elements that are displayed when your field is included in a list view and their display style.

 

Please refer to this sample which will be helpful for your current requirement - https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting#apply-fo...

 

If you are new to column formatting, please refer to this link which will help you to get started - https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting.

@Filipe Matos 

 

Hope this helps. Thanks.

Highlighted

@Swaminathan Sriram 

Thank you, your answer has pointed me in the right direction.

I was able to combine a calculated column with a column formatting to meet my purpose.

 

Best regards

Filipe

Highlighted

@Filipe Matos 

 

There is actually an update rolling out globally that will help do this WITHOUT CODE! It landed in my tenant last week. Good luck - here is a link to the item in the road map. This link shows a lot of updates...but conditional formatting is the one I'm talking about. It's roadmap item 

  • Featured ID: 57305
Highlighted

@Michael Malloy 

Awesome, just checked my tenant and found it too!

Thank you for your hint.