Group measurements by id and type.