@Rob ,
We can add an if condition to all iconName attributes. If a specific choice value is selected, the related icon will be displayed. If not, leave it blank:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"style": {
"font-size": "16px"
},
"children": [
{
"elmType": "span",
"attributes": {
"title": "Test1",
"iconName": "=if((indexOf(join(@currentField,''),'Test1') != -1, 'Precipitation', '')",
"class": "='ms-fontColor-' + if(indexOf(join(@currentField,''),'Test1') != -1, 'themeDark', 'neutralLight')"
},
"style": {
"padding": "0 2px"
}
},
{
"elmType": "span",
"attributes": {
"title": "Test2",
"iconName": "=if((indexOf(join(@currentField,''),'Test2') != -1, 'CoffeeScript', '')",
"class": "='ms-fontColor-' + if(indexOf(join(@currentField,''),'Test2') != -1, 'themeDark', 'neutralLight')"
},
"style": {
"padding": "0 2px 0 0"
}
},
{
"elmType": "span",
"attributes": {
"title": "Test3",
"iconName": "=if((indexOf(join(@currentField,''),'Test3') != -1, 'Wines', '')",
"class": "='ms-fontColor-' + if(indexOf(join(@currentField,''),'Test3') != -1, 'themeDark', 'neutralLight')"
},
"style": {
"padding": "0 2px"
}
},
{
"elmType": "span",
"attributes": {
"title": "Test4",
"iconName": "=if((indexOf(join(@currentField,''),'Test4') != -1, 'BeerMug', '')",
"class": "='ms-fontColor-' + if(indexOf(join(@currentField,''),'Test4') != -1, 'themeDark', 'neutralLight')"
},
"style": {
"padding": "0 2px"
}
}
]
}
Please check my simple test result:
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.