How can I use summarize to add the sum of a calculated column in a table footer?

I am using getStateUsing to calculate the number of hours a client uses for a specific period of time. I would like to add the sum of this value to the table footer.
Tables\Columns\TextColumn::make('hours_used')
    ->getStateUsing(function (Client $record) {
       return $record->timelogs()
                      ->select(
                            DB::raw('DAY(timelogs.created_at), (CEIL(( SUM(timelogs.total_seconds) /3600) / 0.25) * 0.25) as billable' )
                            )
                            ->whereBetween('timelogs.created_at', [$this->startDate, $this->endDate])
                            ->groupBy(DB::raw('client_id, ticket_id, DAY(timelogs.created_at)'))->get()->sum('billable');
                    })
    ->summarize(Sum::make()->using(fn (Builder $query, Client $record): float => $query->sum(
       $record->timelogs()->select(
                            DB::raw('DAY(timelogs.created_at), (CEIL(( SUM(timelogs.total_seconds) /3600) / 0.25) * 0.25) as billable' )
                        )
                        ->whereBetween('timelogs.created_at', [$this->startDate, $this->endDate])
                        ->groupBy(DB::raw('client_id, ticket_id, DAY(timelogs.created_at)'))->get()->sum('billable')
                    ) )),


I think I'm missing something. The error I get is
SQLSTATE[42S22]: Column not found: 1054 Unknown column '3.25' in 'field list'
SELECT sum(`3`.`25`) AS aggregate FROM (SELECT * FROM `clients` WHERE (EXISTS (SELECT * FROM `timelogs` INNER JOIN `tickets` ON `tickets`.`id` = `timelogs`.`ticket_id` WHERE `clients`.`id` = `tickets`.`client_id` AND `timelogs`.`created_at` BETWEEN 2024-07-01 AND 2024-07-31 23:59:59 AND `timelogs`.`deleted_at` IS NULL AND `tickets`.`deleted_at` IS NULL)) AND `clients`.`deleted_at` IS NULL ORDER BY `name` ASC) AS `clients`
Was this page helpful?