© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•12mo ago•
1 reply
phphelloworld

Summarising groups of rows - distinguish group and overall summaries

What I am trying to do:
I have grouping data in a table by description.
Each group shows a correct summary applying the limit check (min($totalPoints , $maxPoints))
But the overall total at the bottom incorrectly applies this same limit to the sum of all groups, rather than simply adding up the already limited group totals.
How to distinguish between group and overall summaries?

What I did:
public function table(Table $table): Table
{
return $table
->defaultGroup('descr')
->columns([
  TextColumn::make('punti')
    ->summarize(Summarizer::make()
        ->label('Total Points')
        ->using(function ($query) {
            $totalPoints = $query->sum('punti'); // Sum of all points
            $maxPoints = $query->value('punti_max'); // Fetches a single value of punti_max (since it is the same for all records in the same group)                            
            return $maxPoints !== null ? min($totalPoints, $maxPoints) : $totalPoints;
        }))
public function table(Table $table): Table
{
return $table
->defaultGroup('descr')
->columns([
  TextColumn::make('punti')
    ->summarize(Summarizer::make()
        ->label('Total Points')
        ->using(function ($query) {
            $totalPoints = $query->sum('punti'); // Sum of all points
            $maxPoints = $query->value('punti_max'); // Fetches a single value of punti_max (since it is the same for all records in the same group)                            
            return $maxPoints !== null ? min($totalPoints, $maxPoints) : $totalPoints;
        }))
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

Summarising groups
FilamentFFilament / ❓┊help
2y ago
Table group of groups?
FilamentFFilament / ❓┊help
17mo ago
Table groups, summaries table but not groups.
FilamentFFilament / ❓┊help
3y ago
Table groups with 5 newest rows per group
FilamentFFilament / ❓┊help
14mo ago