public function groupBy($columns, array $excludeColumns = [])
    {
        $groupedData = [];
        $statsTable = $this->build();

        foreach ($statsTable->getData() as $line) {
            $key = join(
                '-_##_-',
                array_map(
                    function ($c) use ($line) {
                        return $line[$c];
                    },
                    $columns
                )
            );

            $groupedData[$key][] = $line;
        }

        $filterLine = function ($line) use ($excludeColumns) {
            foreach ($excludeColumns as $c) {
                unset($line[$c]);
            }

            return $line;
        };

        $headers = $filterLine(
            array_map(
                function (StatsColumnBuilder $c) {
                    return $c->getHeaderName();
                },
                $this->columns
            )
        );
        $formats = $filterLine(
            array_map(
                function (StatsColumnBuilder $c) {
                    return $c->getFormat();
                },
                $this->columns
            )
        );
        $aggregations = $filterLine(
            array_map(
                function (StatsColumnBuilder $c) {
                    return $c->getAggregation();
                },
                $this->columns
            )
        );
        $metaData = $filterLine(
            array_map(
                function (StatsColumnBuilder $c) {
                    return $c->getMetaData();
                },
                $this->columns
            )
        );

        $data = [];

        foreach ($groupedData as $lines) {
            $tmpAggregations = $aggregations;
            // Add static aggragation for group by fields
            foreach ($columns as $column) {
                $oneLine = current($lines);
                $value = $oneLine[$column];
                $tmpAggregations[$column] = new StaticAggregation($value, Format::STRING);
            }

            $tmpTableBuilder = new StatsTableBuilder(
                array_map($filterLine, $lines),
                $headers,
                $formats,
                $tmpAggregations,
                [],
                [],
                null,
                $metaData
            );
            $tmpTable = $tmpTableBuilder->build();
            $data[] = $tmpTable->getAggregations();
        }

        return new StatsTableBuilder(
            $data,
            $headers,
            $formats,
            $aggregations,
            [],
            [],
            null,
            $metaData
        );
    }