Hi, The initial of the code should be modified, so here is only the essence of one of the pivoting reports: for $singleDataType in $dataType for $singleDevice in $device for $singleAvailability in $availability for $singleCountry in $country for $singleParameter in $parameter group by $singleDataType,$singleDevice,$singleAvailability,$singleCountry,$singleParameter order by $singleDataType,$singleDevice,$singleAvailability,$singleCountry,$singleParameter return <Row DatasetType="{$singleDataType}" Instrument="{$singleDevice}" Availability="{$singleAvailability}" Country="{$singleCountry}" Parameter="{$singleParameter}" NumberOfRecords="{count($current-pre)}"/> Other report will count all records with one less condition: group by $singleDataType,$singleDevice,$singleAvailability,$singleCountry order by $singleDataType,$singleDevice,$singleAvailability,$singleCountry return <Row DatasetType="{$singleDataType}" Instrument="{$singleDevice}" Availability="{$singleAvailability}" Country="{$singleCountry}" Parameter="Any" NumberOfRecords="{count($current-pre)}"/> I hope it's clear. With kind regards, Menashè