This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

cadmojr20164211
cadmojr20164211

I need to do the sum of the values ​​of a column, does anyone know how?

group_value:
      label: 'Adiantamentos Programados'
      type: number
      format: %.2f
      relation: advanceoptions
      select: concat(description,' - ', if(already_paid = 1,value,null)) 
      useRelationCount: false

it is already returning two separate values, but I need the sum.

1,00
3,00

I believe it would be something like useRelationCount:, because it brings the amount of values.

I don't know if there is a similar function to add the values ​​directly in the columns.

Thanks.

Last updated

daftspunky
daftspunky

We recommend using a type: partial for this because the it goes beyond the scope of the list options.

Here is the documentation on this column type: https://octobercms.com/docs/backend/lists#column-partial

Inside the partial, you can add any logic you like. Such as

<?php
$sum = 0;
foreach($record->advanceoptions as $option) {
    $sum += $option;
}

echo $sum;

Hope this helps!

cadmojr20164211
cadmojr20164211

thanks, solved my problem.

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.