Calculate summarize from others summarize

return $table
        ->columns([
            Tables\Columns\TextColumn::make('name')
                ->label('Name'),
            Tables\Columns\TextColumn::make('id')
                ->label('Id'),
            Tables\Columns\TextColumn::make('bet')
                ->label('Bet')
                ->summarize([
                    Sum::make()->label('')
                ])
                ->money('EUR')
                ->color('success'),
            Tables\Columns\TextColumn::make('win')
                ->label('Win')
                ->money('EUR')
                ->color('danger')
                ->summarize([
                    Sum::make()->label('')
                ]),
            Tables\Columns\TextColumn::make('result')
                ->label('Result')
                ->money('EUR')
                ->color(function ($state) {
                    if($state > 0) {
                        return 'success';
                    }
                    return 'danger';
                })
                ->summarize([
                    Sum::make()->label('')
                ]),
            Tables\Columns\TextColumn::make('rtp')
            ->numeric(decimalPlaces: 2)
            ->formatStateUsing(function ($record) {
                return number_format($record->rtp,2,'.').' %';
            })
            ->summarize()->label(''))
            ->label('RTP')
            ->color('success'),
        ])

for rtp I want to calculate an average that depends on the summarize win and summarize bet but I don't know how to do it for the rtp summarize.
Was this page helpful?