1542062 - How to create Hierarchical Numbering for groups in Crystal Reports?

SAP Knowledge Base Article - Public

1542062 - How to create Hierarchical Numbering for groups in Crystal Reports?

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

 

  • Crystal Reports XI R2 (All Patch levels)
  • Crystal Reports 2008 (All Patch levels)
  • Resolution

    1. Create a Crystal Report against the Xtreme Sample Database
    2. Create 3 Groups in the following order (Insert -> Group):
    3. Customer.Country, Customer.City, Customer.Region

    4. Create a formula called ‘TopGroup’(Field Explorer ->Right click ‘Formula fields’ ->New) as follows:
    5. WhilePrintingRecords;

      numbervar x:= x+1;

    6. Place this formula beside Group #1
    7. Create a formula called ‘Level2’ as follows:
    8. WhilePrintingRecords;

      numberVar x;

      numberVar y;

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

    9. Place this formula beside Group #2
    10. Create a formula called ‘Level3’ as follows:
    11. WhilePrintingRecords;

      numberVar x;

      numberVar y;

      numbervar z;

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

    12. Place this beside Group #3
    13. Create a formula called ‘IncLevel2’ as follows:
    14. WhilePrintingRecords;

      numbervar y := y+1;

    15. Place this formula beside the formula called ‘Level2’
    16. Create a formula called ‘IncLevel3’ as follows:
    17. WhilePrintingRecords;

      numbervar z:=z+1;

    18. Place this formula beside the formula called ‘Level3’
    19. Create a formula called ‘ResetLevel2’ as follows:
    20. WhilePrintingRecords;

      numberVar y:= 0;

    21. Place this formula on the Group Footer #1
    22. Create a formula called ‘ResetLevel3’ as follows:
    23. WhilePrintingRecords;

      numbervar z:=0;

    24. Place this formula beside the formula called ‘IncLevel2’
    25. Refresh the report and you’ll see that all the Groups and Sub-groups have correct hierarchical numbering

    Keywords

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

    Product

    Crystal Reports 2008 V0 ; Crystal Reports 2008 V1 ; SAP Crystal Reports XI R2

    Attachments

    Hierarchical Numbering.rpt