How to hide column of structure field, if all fields of this column are empty?

I am using structure field for products catalog and displaying as in table (<table><tr><td>...) There are few categories, that need field, which is not used for any other categories. So I would like to have one structure field with all avaibale fields for entire catalog, but only to hide columns in frontend, if all fields for this columns are empty.

You can use pluck to fetch an array of all values of a given field, e.g

$structure = $page->myStructureField()->toStructure();
$someFieldValues = $structure->pluck('somefield', ',');
if(!empty($someFieldValues)) {
  // do stuff
}

Solved, thanks a lot!