2016-06-14 92 views
0

我必須做一個報表彙總表,它將顯示相同的數據。嘗試使用xdoxslt:distinct_values將相同的值分組,但它不起作用,也不顯示任何錯誤。計數不同值

我現在所擁有的:

001 - 1

002 - 1

001 - 1

我需要實現什麼:

001 - 2

002 - 1

爲了消除對001的不同值I中使用的代碼按照下面

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

使用的代碼按照下面計數不同值嘗試,但它不工作

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

不限建議?

回答

0

distinct_values將只返回不同值的空格分隔列表。根據您的要求,您需要循環每個不同的值並計算其實例。

我用這個XML:

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

這BIP代碼:

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

,並得到這樣的輸出:

001-2 
002-1 
003-1 
0

感謝蘭芝斯!代碼起作用。

我編輯的代碼,如果條件按以下(在sumSub已在報告的頂部聲明)增加了一個

<?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()/.))?> 

的CwaProductCode顯示正確結果,按您的建議。但計數以某種方式顯示結果,好像沒有添加過濾。