Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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', '')"
}
Thank you for your help!
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
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 37 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 130 | |
| 88 | |
| 82 | |
| 68 | |
| 64 |