Add to the data source of the report an additional field where you define the value based on your grouping criteria. Use this field than for grouping of the report.