I think you can do that by updating the original JSON of the Gallery view.
In the original JSON, to show the value, "=if ([$Machine] == '', '-', [$Machine])"
has been used, which now has been replaced with "=if ([$Machine] == '', '', [$Machine])"
.
Also, to show the column name, in the original JSON, "[!Machine.DisplayName]"
been used. However, when I applied conditional (if) to display, it didn't work. So, had to hard-code the column display name with condition, that is, if column has a value then show the display name, otherwise not.
{
"height": 165,
"width": 254,
"hideSelection": false,
"fillHorizontally": true,
"formatter": {
"elmType": "div",
"attributes": {
"class": "sp-card-container"
},
"children": [
{
"elmType": "button",
"attributes": {
"class": "sp-card-defaultClickButton"
},
"customRowAction": {
"action": "defaultClick"
}
},
{
"elmType": "div",
"attributes": {
"class": "ms-bgColor-white sp-css-borderColor-neutralLight sp-card-borderHighlight sp-card-subContainer"
},
"children": [
{
"elmType": "div",
"attributes": {
"class": "sp-card-displayColumnContainer"
},
"children": [
{
"elmType": "p",
"attributes": {
"class": "ms-fontColor-neutralSecondaryAlt sp-card-label"
},
"txtContent": "=if ([$Title] == '', '', 'Title')"
},
{
"elmType": "p",
"attributes": {
"title": "[$Title]",
"class": "ms-fontColor-neutralPrimary sp-card-content sp-card-highlightedContent"
},
"txtContent": "=if ([$Title] == '', '', [$Title])"
}
]
},
{
"elmType": "div",
"attributes": {
"class": "sp-card-displayColumnContainer"
},
"children": [
{
"elmType": "p",
"attributes": {
"class": "ms-fontColor-neutralSecondaryAlt sp-card-label"
},
"txtContent": "=if ([$Name] == '', '', 'Name')"
},
{
"elmType": "p",
"attributes": {
"title": "[$Name]",
"class": "ms-fontColor-neutralPrimary sp-card-content "
},
"txtContent": "=if ([$Name] == '', '', [$Name])"
}
]
},
{
"elmType": "div",
"attributes": {
"class": "sp-card-lastTextColumnContainer"
},
"children": [
{
"elmType": "p",
"attributes": {
"class": "ms-fontColor-neutralSecondaryAlt sp-card-label"
},
"txtContent": "=if ([$Machine] == '', '', 'Machine')"
},
{
"elmType": "p",
"attributes": {
"title": "[$Machine]",
"class": "ms-fontColor-neutralPrimary sp-card-content "
},
"txtContent": "=if ([$Machine] == '', '', [$Machine])"
}
]
}
]
}
]
}
}