Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
James_L
New Member

SharePoint List View Formatting with JSON: How to show if entry has attachment or not

Hello

 

I am currently developing a dashboard by editing a Sharepoint List view with JSON and trying to figure out how to show if an entry has an attachement or not.  In the code below I have a checkbox field for "savings" that performs what I want, but I can not get the "Attachements" field to do the same. Currently every entry shows the "X" value regardless if it has an attachement or not.

 

{
"elmType": "span",
"attributes": {
"class": "=if([$Savings] == True, 'ms-fontColor-white ms-bgColor-green ms-fontSize-l','')"
},
"style": {
"border-radius": "50%",
"vertical-align": "text-bottom",
"margin-left": "25px",
"line-height": "2em",
"padding-left": "8px",
"padding-right": "8px",
"padding-bottom": "2px"
},
"txtContent": "=if([$Savings] == True, '$',''"
},
{
"elmType": "span",
"attributes": {
"class": "=if(toString[$Attachments] == '', 'ms-fontColor-white ms-bgColor-black ms-fontSize-l','')"
},
"style": {
"border-radius": "50%",
"vertical-align": "text-bottom",
"margin-left": "25px",
"line-height": "2em",
"padding-left": "8px",
"padding-right": "8px",
"padding-bottom": "2px"
},
"txtContent": "=if(toString[$Attachments] == '', 'X', '')"
}image.png

 

Thank you for your help!

 

2 REPLIES 2
v-xicai
Community Support
Community Support

Hi @James_L ,

 

You can try to change it like code below( Pay attention to the red font words ), go through the link to learn more : https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting .

 

{

"elmType": "span",

"attributes": {

"class": "=if([$Savings] == True, 'ms-fontColor-white ms-bgColor-green ms-fontSize-l','')"

},

"style": {

"border-radius": "50%",

"vertical-align": "text-bottom",

"margin-left": "25px",

"line-height": "2em",

"padding-left": "8px",

"padding-right": "8px",

"padding-bottom": "2px"

},

"txtContent": "=if([$Savings] == True, '$','')"

},

{

"elmType": "span",

"attributes": {

"class": "=if([$Attachments] == True, 'ms-fontColor-white ms-bgColor-black ms-fontSize-l','')"

},

"style": {

"border-radius": "50%",

"vertical-align": "text-bottom",

"margin-left": "25px",

"line-height": "2em",

"padding-left": "8px",

"padding-right": "8px",

"padding-bottom": "2px"

},

"txtContent": "=if([$Attachments] == True, 'X', '')"

 

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for the attempt @v-xicai . Unfortunately this did not work.

 

Below are variations I've attempted with no success (Does not include variations resulting in an error). Also note i have tried adding "toString" to all of these.

 

1. "=if(toString([$Attachments]) == '', 'X', '')"

2. "=if([$Attachments] == True, '', 'X')"

3. "=if([$Attachments.fileName] == '', 'X', '')"

4. "=if([$Attachments.value] == '', 'X', '')"

5. "=if([$Attachments.title] == '', 'X', '')"

6. "=if([$Attachments] == 'Yes', '', 'X')"

7. "=if(toString([$Attachments]) == 'Yes', '', 'X')"

8. "=if(toString([$Attachments.lookupValue]) == 'Yes', '', 'X')"

 

regards

James

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.