SOLVED

List conditional formatting with multiple conditions and column references

%3CLINGO-SUB%20id%3D%22lingo-sub-2253416%22%20slang%3D%22en-US%22%3EList%20conditional%20formatting%20with%20multiple%20conditions%20and%20column%20references%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2253416%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22list.jpg%22%20style%3D%22width%3A%20727px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F269429i6770CADE1B0626C1%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22list.jpg%22%20alt%3D%22list.jpg%22%20%2F%3E%3C%2FSPAN%3EI%20used%20the%20interface%20to%20create%20the%20first%20condition%20on%20each%20column%20to%20highlight%20required%20information%2C%20logic%20for%20which%20is%20the%20following%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20Expired%20%3D%20Y%2C%20then%20Expired%20Explanation%20turns%20orange%20(required).%20If%20'Other...'%20is%20chosen%20in%20Expired%20Explanation%2C%20then%20the%20Comments%20field%20turns%20orange.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20wish%20to%20add%20(via%20JSON%20I%20believe%20is%20the%20only%20way%2C%20since%20I%20can't%20find%20any%20OR%20options%20in%20the%20'wizard')%20to%20this%20the%20following%20conditions%3A%3CBR%20%2F%3EIf%20Expired%20%3D%20Y%2C%20then%20Expired%20Explanation%20turns%20orange%20(required).%20%3CSTRONG%3EThen%2C%20when%20Expired%20Explanation%20is%20completed%20(a%20choice%20is%20selected)%2C%20it%20turns%20pale%20green.%3C%2FSTRONG%3E%20If%20'Other...'%20%3CSTRONG%3Eor%20'Renewed'%3C%2FSTRONG%3E%20is%20chosen%20in%20Expired%20Explanation%2C%20then%20the%20Comments%20field%20turns%20orange.%3CSTRONG%3E%20Then%2C%20when%20Comments%20is%20completed%2C%20it%20turns%20pale%20green.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSTRONG%3EI%20have%20searched%20and%20read%20and%20experimented%20but%20I%20am%20having%20a%20hard%20time%20understanding%20JSON%20syntax%20especially%20when%20I%20compare%20examples%20to%20the%20code%20that%20the%20'wizard'%20is%20generating%20for%20the%20orange%20effect.%3CBR%20%2F%3E%3CBR%20%2F%3EMany%20thanks%20for%20your%20help.%20I%20will%20have%20two%20more%20sets%20of%20these%20three-column%20contingencies%20when%20complete.%20(I%20tried%20validations%20first%2C%20but%20after%20several%20days%20abandoned%20that!%20%3A(%3C%2Fimg%3E%20)%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2253416%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ELists%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2253833%22%20slang%3D%22en-US%22%3ERe%3A%20List%20conditional%20formatting%20with%20multiple%20conditions%20and%20column%20references%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2253833%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1011163%22%20target%3D%22_blank%22%3E%40TanyaMc%3C%2FA%3E%26nbsp%3Byes%20you%20can%20do%20this%20and%20the%20result%20is%20shown%20below%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%220-SP-list.png%22%20style%3D%22width%3A%20783px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F269446i63E3F8246F34DF0D%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%220-SP-list.png%22%20alt%3D%220-SP-list.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20the%20Explanation%20column%20the%20JSON%26nbsp%3B%20that%20you%20need%20to%20paste%20into%20the%20Advanced%20mode%20window%20is%20as%20follows%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%22%24schema%22%3A%20%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fcolumn-formatting.schema.json%22%2C%0A%20%20%22elmType%22%3A%20%22div%22%2C%0A%20%20%22txtContent%22%3A%20%22%40currentField%22%2C%0A%20%20%22style%22%3A%20%7B%0A%20%20%20%20%22padding-left%22%3A%20%2214px%22%2C%0A%20%20%20%20%22background-color%22%3A%20%22%3Dif(%40currentField%20%3D%3D%20''%20%26amp%3B%26amp%3B%20%5B%24Expired%5D%20%3D%3D%20'Y'%2C%20'%23ff7e00'%2C%20if(%40currentField%20!%3D%20''%20%2C'%2385b18e'%2C%20'%23cacfd6')%22%2C%0A%20%20%20%20%22color%22%3A%20%22white%22%0A%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20the%20Comments%20column%20the%20JSON%20is%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%22%24schema%22%3A%20%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fcolumn-formatting.schema.json%22%2C%0A%20%20%22elmType%22%3A%20%22div%22%2C%0A%20%20%22txtContent%22%3A%20%22%40currentField%22%2C%0A%20%20%22style%22%3A%20%7B%0A%20%20%20%20%22padding-left%22%3A%20%2214px%22%2C%0A%20%20%20%20%22background-color%22%3A%20%22%3Dif(%40currentField%20!%3D%20''%2C%20'%2385b18e'%2C%20if((%5B%24Explanation%5D%20%3D%3D%20'Other%20(provide%20comments)'%20%7C%7C%20(%5B%24Explanation%5D%20%3D%3D%20'Renewed')%2C'%23ff7e00'%2C%20'%23cacfd6'%20)%22%2C%0A%20%20%20%20%22color%22%3A%20%22white%22%0A%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20that%20helps.%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.%3CBR%20%2F%3EIf%20I've%20answered%20your%20question%20or%20solved%20your%20problem%2C%20please%20mark%20this%20question%20as%20answered.%20This%20helps%20others%20who%20have%20the%20same%20question%20find%20a%20solution%20quickly%20via%20the%20forum%20search.%20If%20you%20liked%20my%20response%2C%20please%20consider%20giving%20it%20a%20thumbs%20up.%20Thanks.%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

list.jpgI used the interface to create the first condition on each column to highlight required information, logic for which is the following:

 

If Expired = Y, then Expired Explanation turns orange (required). If 'Other...' is chosen in Expired Explanation, then the Comments field turns orange.

 

I wish to add (via JSON I believe is the only way, since I can't find any OR options in the 'wizard') to this the following conditions:
If Expired = Y, then Expired Explanation turns orange (required). Then, when Expired Explanation is completed (a choice is selected), it turns pale green. If 'Other...' or 'Renewed' is chosen in Expired Explanation, then the Comments field turns orange. Then, when Comments is completed, it turns pale green.

I have searched and read and experimented but I am having a hard time understanding JSON syntax especially when I compare examples to the code that the 'wizard' is generating for the orange effect.

Many thanks for your help. I will have two more sets of these three-column contingencies when complete. (I tried validations first, but after several days abandoned that! I could only get one validation in one of the nine columns to work. :( )


2 Replies
best response confirmed by TanyaMc (New Contributor)
Solution

@TanyaMc yes you can do this and the result is shown below:

 

0-SP-list.png

 

For the Explanation column the JSON  that you need to paste into the Advanced mode window is as follows:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "padding-left": "14px",
    "background-color": "=if(@currentField == '' && [$Expired] == 'Y', '#ff7e00', if(@currentField != '' ,'#85b18e', '#cacfd6')",
    "color": "white"
  }
}

 

For the Comments column the JSON is:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "padding-left": "14px",
    "background-color": "=if(@currentField != '', '#85b18e', if(([$Explanation] == 'Other (provide comments)' || ([$Explanation] == 'Renewed'),'#ff7e00', '#cacfd6' )",
    "color": "white"
  }
}

 

Hope that helps.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User.
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.