0

I have to do a report summary table that will be displaying the same data. Tried using the xdoxslt:distinct_values to group the same value but it does not work nor it displays any error.

What I have right now:

001 - 1

002 - 1

001 - 1

What I need to achieve:

001 - 2

002 - 1

To eliminate the distinct values for the 001 I used the code as per below

<?CwaProductCode[not(.=preceding::CwaProductCode)]?>

Tried using the code as per below to count the distinct values but it does not work

<?count(xdoxslt:distinct_values(CwaProductCode))?>

Any suggestions?

Yan
  • 35
  • 1
  • 4
  • 10

2 Answers2

0

distinct_values will only return a space separated list of the distinct values. For your requirement, you will need to loop though each distinct value and count its instance.

I used this xml:

<ROWSET>
    <ROW>
        <CwaProductCode>001</CwaProductCode>
    </ROW>
    <ROW>
        <CwaProductCode>002</CwaProductCode>
    </ROW>
    <ROW>
        <CwaProductCode>001</CwaProductCode>
    </ROW>
    <ROW>
        <CwaProductCode>003</CwaProductCode>
    </ROW>
</ROWSET>

And this BIP code:

<?for-each-group:ROW;./CwaProductCode?>
<?CwaProductCode?><?'-'?><?count(current-group()/.)?>
<?end for-each-group?>

And got this output:

001-2
002-1
003-1
Ranjith R
  • 1,571
  • 1
  • 11
  • 11
0

Thanks Ranjith! The code works.

I edited the code and added an if condition as per below (the sumSub has been declared at the top of the report)

<?for-each-group:ROW;./CwaProductCode?>
<?if:CwaOrderType='UT Sales' and CwaChannel='Customer Portal'?>
<?CwaProductCode[not(.=preceding::CwaProductCode)]?>
<?count(current-group()/.)?>
<?xdoxslt:set_variable($_XDOCTX, 'sumSub', xdoxslt:get_variable($_XDOCTX,'sumSub')+count(current-group()/.))?>

The CwaProductCode displays the correct result as per your suggestions. But the count somehow displays the result as if there was no filtering added.

Yan
  • 35
  • 1
  • 4
  • 10