© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
4 replies
Oleksandr

Error When Displaying Aggregated Data in Filament Resource Table

Hello everyone,

I need assistance with an issue, please. I have a model that requires data aggregation (calculating sums by group). Afterwards, I'd like to display these aggregated data in a resource table. To transform the data, I'm using Eloquent:
return $table->modifyQueryUsing(function (Builder $query) use ($today) {
        $query->where('dt', '>=', $today)
            ->groupBy('hour')
            ->selectRaw('DATE_FORMAT(dt, "%H:00") as hour, SUM(rounded) as total_sum');
    })

    ->columns([
        Tables\Columns\TextColumn::make('hour'),
        Tables\Columns\TextColumn::make('total_sum'),
    ]);
return $table->modifyQueryUsing(function (Builder $query) use ($today) {
        $query->where('dt', '>=', $today)
            ->groupBy('hour')
            ->selectRaw('DATE_FORMAT(dt, "%H:00") as hour, SUM(rounded) as total_sum');
    })

    ->columns([
        Tables\Columns\TextColumn::make('hour'),
        Tables\Columns\TextColumn::make('total_sum'),
    ]);


However, I'm encountering an error: "Filament\Resources\Pages\ListRecords::getTableRecordKey(): Return value must be of type string, null returned." I understand that ListRecords requires an ID value from the model's record. However, after data transformation, this ID value is no longer present.

Could you please advise on how to solve this issue or suggest a workaround?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Sort data in Resource Table
FilamentFFilament / ❓┊help
3y ago
format data in filament table
FilamentFFilament / ❓┊help
17mo ago
The data is not displaying in the Filament Table Builder v2.
FilamentFFilament / ❓┊help
2y ago
Filament Resource Error
FilamentFFilament / ❓┊help
2y ago