### Symptom

- How to create Hierarchical Numbering for groups in Crystal Reports?
- For e.g.:

Country1 1

City1 1.1

Region1 1.1.1

City2 1.2

Region1 1.2.1

Region2 1.2.2

Country 2 2

And so on...

### Environment

### Resolution

- Create a Crystal Report against the Xtreme Sample Database
- Create 3 Groups in the following order (Insert -> Group):
- Create a formula called ‘TopGroup’(Field Explorer ->Right click ‘Formula fields’ ->New) as follows:
- Place this formula beside Group #1
- Create a formula called ‘Level2’ as follows:
- Place this formula beside Group #2
- Create a formula called ‘Level3’ as follows:
- Place this beside Group #3
- Create a formula called ‘IncLevel2’ as follows:
- Place this formula beside the formula called ‘Level2’
- Create a formula called ‘IncLevel3’ as follows:
- Place this formula beside the formula called ‘Level3’
- Create a formula called ‘ResetLevel2’ as follows:
- Place this formula on the Group Footer #1
- Create a formula called ‘ResetLevel3’ as follows:
- Place this formula beside the formula called ‘IncLevel2’
- Refresh the report and you’ll see that all the Groups and Sub-groups have correct hierarchical numbering

Customer.Country, Customer.City, Customer.Region

WhilePrintingRecords;

numbervar x:= x+1;

WhilePrintingRecords;

numberVar x;

numberVar y;

totext(x,0)+"."+totext(y,0);

WhilePrintingRecords;

numberVar x;

numberVar y;

numbervar z;

totext(x,0)+"."+totext(y,0)+"."+totext(z,0);

WhilePrintingRecords;

numbervar y := y+1;

WhilePrintingRecords;

numbervar z:=z+1;

WhilePrintingRecords;

numberVar y:= 0;

WhilePrintingRecords;

numbervar z:=0;

### Keywords

Hierarchical Numbering, Crystal Reports , KBA , BI-RA-CR , Crystal Reports designer or BusinessViews Manager , How To

### Product

### Attachments

Hierarchical Numbering.rpt |