in src/dataViewBuilder/dataViewBuilder.ts [486:517]
function groupValues(values: DataViewValueColumn[]): DataViewValueColumnGroup[] {
    let groups: DataViewValueColumnGroup[] = [],
        currentGroup: DataViewValueColumnGroup;
    for (let i = 0, len = values.length; i < len; i++) {
        let value = values[i];
        if (!currentGroup || currentGroup.identity !== value.identity) {
            currentGroup = {
                values: []
            };
            if (value.identity) {
                currentGroup.identity = value.identity;
                let source = value.source;
                // allow null, which will be formatted as (Blank).
                if (source.groupName !== undefined)
                    currentGroup.name = source.groupName;
                else if (source.displayName)
                    currentGroup.name = source.displayName;
            }
            groups.push(currentGroup);
        }
        currentGroup.values.push(value);
    }
    return groups;
}