@Eto This is possible, but it won’t be very efficient since the query has to read the data twice (once to count the number of rows and another to aggregate the data). To make sure the query is as optimized as possible, structure the base dataset as a function. This allows pushdowns to continue beyond the data variable declaration.