I have a solution that I've repurposed quite a few times. Here's an Arcade expression where the return is an HTML table that will include only attributes that have a value present. You'll have to switch out the attributes to match your own.
// Use Arcade > Text template
// create one expression for all fields
// return as table showing only populated fields
// If field is null, do not add row to table
// if field has a value, add row to table
// Create variables for checked-for-field and what their labels should be.
// Select the fields to look for
var fieldsArray = ['Condition','Install_Date','Location','Intersection_Type','Facility_Type','Ramp_Config','Managed_By','Comments'];
// Set the field aliases in the same order as the fields above
var labelsArray = ['Condition','Install Date','Location','Intersection Type','Facility Type','Ramp Configuration','Managed By','Comments'];
var arrayLength = Count( fieldsArray );
// Table Header
// Identify condition and set background color accordingly
var cond = $feature.Condition
var backgroundColor = When(cond=="1 (Non-existant)","#fc461d",cond=="2 (Poor)","#df750c",cond=="3 (Functional)","#f2cc0d",cond=="4 (ADA Compliant)","#37aac4","#cccccc")
// Set table header
var returnString = `<h3 style="background-color:${backgroundColor};padding-left:2%">Ramp Info</h3><table style="width:100%;background-color:#f4f4f4;">`;
// Make sure the final table is searching for correct attributes
Expects( $feature, 'Condition','Install_Date','Location','Intersection_Type','Facility_Type','Ramp_Config','Managed_By','Comments')
/*loops through a number of times eual to the length of the array (that's the i<arrayLength part), incrementing by one each time (i++). If the attribute if the field array is not empty
(!IsEmpty), then the value of the the variable returnString is equal the value in the fieldsArray equal to the index value of the array (fieldsArray[i]) plus the additional portion of the
return string enclosed in the curly brackets. If it is empty, then the value of returnString
*/
for (var i = 0; i < arrayLength; i++ ) {
if ( !IsEmpty( $feature[ fieldsArray[i] ] ) ){
//returnString = returnString + "<tr><td>" + labelsArray[i] + "</td><td>" + $feature[ fieldsArray[i] ] + "</td></tr>";
returnString = `${returnString}<tr><td style="border-bottom: 1px solid #cccccc;border-right: 1px solid #cccccc;width:50%;padding-left:2%"><b>${labelsArray[i]}</b></td><td style="border-bottom: 1px solid #cccccc;width:50%;padding-left:2%">${$feature[ fieldsArray[i] ]}</td></tr>`;
}}
returnString = returnString + "</table>";
return {
type : 'text',
text : returnString
}
Here's what the result looks like (note that I also used one of the attributes, Condition, to determine the background color of the header: