diff --git a/packages/report-server/src/reportBuilder/transform/aliases/entityMetadataAliases.ts b/packages/report-server/src/reportBuilder/transform/aliases/entityMetadataAliases.ts index f32bcbc192..47634f045e 100644 --- a/packages/report-server/src/reportBuilder/transform/aliases/entityMetadataAliases.ts +++ b/packages/report-server/src/reportBuilder/transform/aliases/entityMetadataAliases.ts @@ -27,6 +27,10 @@ export const insertNumberOfFacilitiesColumn = { ); } + if (table.length() === 0) { + return table; // Skip if the table is empty + } + const organisationUnitValues = table.getColumnValues('organisationUnit'); const numberOfFacilitiesColumnValues = organisationUnitValues.map(organisationUnit => { if (typeof organisationUnit !== 'string') {