XML Tag grouping in RTF Template to suppress duplicates

7.1k Views Asked by At

My XML Tag generated is as follows-

<P_MONTH>01</P_MONTH>


-<G_1>

<DIVISION>CA Division</DIVISION>

<DISTRICT>CA District</DISTRICT>

<DEPARTMENT>Global Operations</DEPARTMENT>

<DEP_EMPL_COUNT>9</DEP_EMPL_COUNT>

</G_1>


-<G_1>

<DIVISION>CA Division</DIVISION>

<DISTRICT>CA District</DISTRICT>

<DEPARTMENT>Laboratory Services</DEPARTMENT>

<DEP_EMPL_COUNT>11</DEP_EMPL_COUNT>

</G_1>


-<G_1>

<DIVISION>CA Division</DIVISION>

<DISTRICT>CA District</DISTRICT>

<DEPARTMENT>Corporate</DEPARTMENT>

<DEP_EMPL_COUNT>3</DEP_EMPL_COUNT>

</G_1>


-<G_1>

<DIVISION>CA Division</DIVISION>

<DISTRICT>S District</DISTRICT>

<DEPARTMENT>Corporate Administration</DEPARTMENT>

<DEP_EMPL_COUNT>6</DEP_EMPL_COUNT>

</G_1>


-<G_1>

<DIVISION>CA Division</DIVISION>

<DISTRICT>S District</DISTRICT>

<DEPARTMENT>Corporate Technology</DEPARTMENT>

<DEP_EMPL_COUNT>1</DEP_EMPL_COUNT>

</G_1>

When I am using these tag like below in the RTF template-

DIVISION                            DISTRICT                    DEPARTMENT                 COUNT
<?for-each:G_1?> <DIVISION>         <DISTRICT>                   <DEPARTMENT>             <COUNT> <?end for-each?>

This is giving an output like -

DIVISION              DISTRICT                          DEPARTMENT                      COUNT
CA Division           CA District                     Global Operations                  9
CA Division           CA District                     Laboratory Services                11
CA Division           CA District                     Corporate                          3
CA Division           S District                      Corporate Administration           6 
CA Division           S District                      Corporate Technology               1

I want the repeated values in division and district to be suppressed and the output to look like -

DIVISION              DISTRICT                          DEPARTMENT                      COUNT
CA Division           CA District                     Global Operations                  9
                                                      Laboratory Services                11
                                                      Corporate                          3
                      S District                      Corporate Administration           6 
                                                      Corporate Technology               1

How can this be achieved ? I am not being able to use for-each-group properly to group the tags. Can someone please help ?

2

There are 2 best solutions below

0
On BEST ANSWER

You can also use variables. Something like this:

RTF enter image description here Make sure you put your "if" logic in the alt-text/field properties, else, it may not work. I took it out so you could see it better here.

Output enter image description here

5
On

I'd use nested tables and for-each-group functionality.

RTF: enter image description here

Output enter image description here