Summary of all the column values

Hello! I created this text column that shows the total sum of every row I have in the table:
Tables\Columns\TextColumn::make('sum_total_row')
->label('Activities Total')
->default( fn(Model $record) => $record->activities->sum('pivot.attributeX'))
->money('EUR')
->summarize(Summarizer::make()
->label('Total')
->using(fn () => 888)
);
Tables\Columns\TextColumn::make('sum_total_row')
->label('Activities Total')
->default( fn(Model $record) => $record->activities->sum('pivot.attributeX'))
->money('EUR')
->summarize(Summarizer::make()
->label('Total')
->using(fn () => 888)
);
I also want to show the total sum of this specific column values. I managed to show a hardcoded number (888) above the column, but I can't show the dynamic sum. I can't use the standard way to calculate the column sum, because this is not a DB column, it's dynamically created in my ManageRelatedRecords class. Thanks!
2 Replies
nicobrave
nicobrave2mo ago
Anyone can help?
Matthew
Matthew2mo ago
Sum the original data, rather than trying to sum your subtotals
Want results from more Discord servers?
Add your server