public function sortByDimensionValue($direction)
    {
        if ($this->id != '$value') {
            throw new AnalyticsDbException('In order to sort by dimension value, you need to first group by dimension value.');
        }

        $direction = (int)$direction;

        $this->pipeline['$sort'] = ['_id.value' => $direction];


        return $this;
    }