summarize time interval
Hi.
I have a "hours" field in my database, containig time user works in a task
My column is:
TextColumn::make('hours')
->label('Duración')
->time()
->summarize(Sum::make()->label('Tiempo trabajado'))
->sortable(),
But "total" is not calculated ok.
how can I calculate correct time sum?
23 Replies
Anyone?
Use a custom summarizer with a custom query, something like:
https://filamentphp.com/docs/3.x/tables/summaries
Custom summaries are "using" a query... don't know how to implement it
$query->raw()
?but, how to apply to filtered records?
I've done it for a basic table, but don't know how to do it in filament
Anyone?
using $query->sum() ?
then combine with your logic to convert from seconds to H:i:s
I had to create a column "seconds" = TIME_TO_SEC(hours) but when I summarize, it give me sum(seconds), I need to formar it H:i:s now, theres no formatUsing func to Summarize
Can you provide the code you are using?
so as above see:
https://filamentphp.com/docs/3.x/tables/summaries#custom-summaries
you can format the display for you. As you are summing duration this is a time which needs diving by 60 etc.
This doesn't work
Solution
just use the original
hours
column is enoughThanks for your answer!!
Is this Filament 2 ?
I'm trying to implement and I get errors
Sum <> Summarizer
Builder <> QueryBuilder...
its filament 3
QueryBuilder = Illuminate\Database\Query\Builder
Done!!!!
Thanks!!! I coulnd't find the right sintax!
youre welcome