Question: I've been searching for a way to count the amount of numbers in one row column spaced by ",". (But nothing found, I use MySQL and what to count with the use of PHP) This is going to be done for whole the database to find the total amount of numbers (by 100'reds). What I do is storing multiple numbers like the following.

100, 200, 300, 400

What I want is to get the amount of numbers in this column to be 4 and add this to the next row column number. Which could be

200 

and therefore equal to 1 + 4 = 5. 

To show it the database way see here
See database sample if it helps

[![enter image description here](https://i.stack.imgur.com/SMMDr.png)](https://i.stack.imgur.com/SMMDr.png)

The total number should then endup beeing 6. 

I want to hear if it is possible in someway to do this? 

Thanks in advance :)

Answer: 
As it turned out, I just had to connect to the datasource, and store an array of elements that were the rendered rows from the table:

```
ngOnChanges(changes: SimpleChanges) {
    this.dataSource.sort = this.sort;
    this.dataSource.connect().subscribe(d => this.renderedData = d);
}

```

Then I could iterate through that collection instead:

```
// And this performs the actual selection.
private selectRowsBetween(start, end) {
    let currentIndex = 0;
    this.renderedData.forEach(row => {
        if (currentIndex >= start && currentIndex <= end) {
            this.selection.select(row);
        }
        currentIndex++;
    });
}

```
Add this line to mat-checkbox

(click)="$event.stopPropagation(); ShiftKeyDown($event, i +
(paginator.pageIndex \* paginator.pageSize));"

```
<ng-container matColumnDef="Select" class="mr-2 mt-2">
  <th mat-header-cell *matHeaderCellDef [hidden]="model.StepCode != 'not_started'">
    <mat-checkbox (change)="$event ? masterToggle() : null; checked()"
      [checked]="selection.hasValue() && isAllSelected()"
      [indeterminate]="selection.hasValue() && !isAllSelected()" [aria-label]="checkboxLabel()">
    </mat-checkbox>
  </th>
  <td mat-cell *matCellDef="let row; let i = index" [hidden]="model.StepCode != 'not_started'">
    <mat-checkbox
      (click)="$event.stopPropagation(); ShiftKeyDown($event, i + (paginator.pageIndex * paginator.pageSize));"
      (change)="
        $event ? selection.toggle(row) : null; checked()" [checked]="selection.isSelected(row)"
      [aria-label]="checkboxLabel(row)">
    </mat-checkbox>
  </td>
</ng-container>

```

Create this method in typescript

```
 lastSelectedSegmentRow = 1; // this is the variable which holds the last selected row index
 ShiftKeyDown(event, lastRow) {
    if (event.shiftKey) {
      let obj: SegmentFile[] = Object.assign([], this.dataSource.data).filter((val, i) => {
        return i > this.lastSelectedSegmentRow && i < lastRow
      });

      obj.forEach(e => this.selection.select(e))
    }
    this.lastSelectedSegmentRow = lastRow;
  }

```