© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•15mo ago•
11 replies
bionary

Can I sort table on non-column data

I know tables sort at the SQL level. That's why sorting like this does not work out of the box in Filament:
 TextColumn::make('days-past-due')->label('Past due')
                    ->color('danger')
                    ->visible(fn ($livewire) => $livewire->activePresetView == 'to-do-now')
                    ->sortable()
                    ->getStateUsing(function($record){
                        $followUpDate = $record->client_events->sortBy('follow_up_on')->firstWhere('is_complete', false)?->follow_up_on;
                        if($followUpDate){
                            $daysPastDue = ceil(now()->diffInDays($followUpDate));//will be negative so round up
                            return "$daysPastDue days";
                        }
                    }),
 TextColumn::make('days-past-due')->label('Past due')
                    ->color('danger')
                    ->visible(fn ($livewire) => $livewire->activePresetView == 'to-do-now')
                    ->sortable()
                    ->getStateUsing(function($record){
                        $followUpDate = $record->client_events->sortBy('follow_up_on')->firstWhere('is_complete', false)?->follow_up_on;
                        if($followUpDate){
                            $daysPastDue = ceil(now()->diffInDays($followUpDate));//will be negative so round up
                            return "$daysPastDue days";
                        }
                    }),


What I am doing above is presenting the oldest date (in days) to the user via that little internal query there.

Does anybody have any idea on how to sort based on some information that is not stored in the table? I'm out of ideas.
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

Non-database Data Table
FilamentFFilament / ❓┊help
2y ago
Sort data in Resource Table
FilamentFFilament / ❓┊help
3y ago
How can I sort by value string on table?
FilamentFFilament / ❓┊help
16mo ago
How can I sort by a custom Column
FilamentFFilament / ❓┊help
3y ago