在 xml bi publisher 中按组计算
count dictinctly by group in xml bi publisher
所以我必须做一个报告,根据 CwaChannel 和 CwaOrderType 清楚地显示和计算 CwaProductCode。
这是我的 xml:
<OrderEntry-Orders>
<CwaChannel>Customer Portal</CwaChannel>
<CwaOrderType>UT Sales</CwaOrderType>
<ListOfOrderEntry-LineItems>
<OrderEntry-LineItems>
<CwaLineTotalAmount2>1000</CwaLineTotalAmount2>
<CwaProductCode>001</CwaProductCode>
</OrderEntry-LineItems>
<OrderEntry-LineItems>
<CwaLineTotalAmount2>1000</CwaLineTotalAmount2>
<CwaProductCode>005</CwaProductCode>
</OrderEntry-LineItems>
</ListOfOrderEntry-LineItems>
</OrderEntry-Orders>
<OrderEntry-Orders>
<CwaChannel>Customer Portal</CwaChannel>
<CwaOrderType>UT Sales</CwaOrderType>
<ListOfOrderEntry-LineItems>
<OrderEntry-LineItems>
<CwaLineTotalAmount2>1000</CwaLineTotalAmount2>
<CwaProductCode>005</CwaProductCode>
</OrderEntry-LineItems>
</ListOfOrderEntry-LineItems>
</OrderEntry-Orders>
<OrderEntry-Orders>
<CwaChannel>Customer Portal</CwaChannel>
<CwaOrderType>UT Redemption</CwaOrderType>
<ListOfOrderEntry-LineItems>
<OrderEntry-LineItems>
<CwaLineTotalAmount2>1000</CwaLineTotalAmount2>
<CwaProductCode>005</CwaProductCode>
</OrderEntry-LineItems>
</ListOfOrderEntry-LineItems>
</OrderEntry-Orders>
这是我的 BIP 代码:
<?for-each-group: OrderEntry-LineItems; CwaProductCode?>
<?if:../../CwaOrderType='UT Sales' and ../../CwaChannel='Customer Portal'?>
<?for-each: current-group()?>
<?CwaProductCode?>
<?xdoxslt:set_variable($_XDOCTX, 'countFund', xdoxslt:get_variable($_XDOCTX, 'countFund')+1)?>
<?xdoxslt:set_variable($_XDOCTX, 'TotalCount', xdoxslt:get_variable($_XDOCTX, 'TotalCount')+1)?>
<?xdoxslt:get_variable($_XDOCTX, 'countFund')?>
<?xdoxslt:set_variable($_XDOCTX, 'countFund', 0)?>
<?end if?>
<?end for-each-group?>
<?xdoxslt:get_variable($_XDOCTX, 'TotalCount')?>
但是出来的结果好像没有if条件。
例如,CwaProductCode 将显示正确的结果,但它会将所有内容一起计算,就好像根本没有过滤一样。
不确定哪里出错了。
进行分组后,访问该分组上方的任何父级 returns 不明确数据。它可能总是指向第一个 'OrderEntry-Orders' 节点。如果更改 xml.
中元素的顺序,您会看到这一点
如果您的要求是仅对具有 CwaOrderType='UT Sales' 和 .CwaChannel='Customer Portal' 的那些 'OrderEntry-LineItems' 节点进行分组,您可以像这样在分组中赋予该过滤器:
<?for-each-group: OrderEntry-LineItems[../../CwaOrderType='UT Sales' and ../../CwaChannel='Customer Portal']; CwaProductCode?>
试试这个代码:
<?for-each-group: OrderEntry-LineItems[../../CwaOrderType='UT Sales' and ../../CwaChannel='Customer Portal']; CwaProductCode?>
<?for-each: current-group()?>
<?CwaProductCode?>
<?xdoxslt:set_variable($_XDOCTX, 'countFund', xdoxslt:get_variable($_XDOCTX, 'countFund')+1)?>
<?xdoxslt:set_variable($_XDOCTX, 'TotalCount', xdoxslt:get_variable($_XDOCTX, 'TotalCount')+1)?>
<?xdoxslt:get_variable($_XDOCTX, 'countFund')?>
<?xdoxslt:set_variable($_XDOCTX, 'countFund', 0)?>
<?end for-each-group?>
<?xdoxslt:get_variable($_XDOCTX, 'TotalCount')?>
给出这个结果:
001
1
1
005
1
005
1
3
<?for-each-group: OrderEntry-LineItems[../../CwaOrderType='UT Sales' and ../../CwaChannel='Customer Portal']; CwaProductCode?>
<?CwaProductCode?>
<?count(current-group()/.)?>
<?xdoxslt:set_variable($_XDOCTX, 'TotalCount', xdoxslt:get_variable($_XDOCTX, 'TotalCount')+ count(current-group()/.))?>
<?end for-each-group?>
<?xdoxslt:get_variable($_XDOCTX, 'TotalCount')?>
给予
001
1
005
2
3
所以我必须做一个报告,根据 CwaChannel 和 CwaOrderType 清楚地显示和计算 CwaProductCode。
这是我的 xml:
<OrderEntry-Orders>
<CwaChannel>Customer Portal</CwaChannel>
<CwaOrderType>UT Sales</CwaOrderType>
<ListOfOrderEntry-LineItems>
<OrderEntry-LineItems>
<CwaLineTotalAmount2>1000</CwaLineTotalAmount2>
<CwaProductCode>001</CwaProductCode>
</OrderEntry-LineItems>
<OrderEntry-LineItems>
<CwaLineTotalAmount2>1000</CwaLineTotalAmount2>
<CwaProductCode>005</CwaProductCode>
</OrderEntry-LineItems>
</ListOfOrderEntry-LineItems>
</OrderEntry-Orders>
<OrderEntry-Orders>
<CwaChannel>Customer Portal</CwaChannel>
<CwaOrderType>UT Sales</CwaOrderType>
<ListOfOrderEntry-LineItems>
<OrderEntry-LineItems>
<CwaLineTotalAmount2>1000</CwaLineTotalAmount2>
<CwaProductCode>005</CwaProductCode>
</OrderEntry-LineItems>
</ListOfOrderEntry-LineItems>
</OrderEntry-Orders>
<OrderEntry-Orders>
<CwaChannel>Customer Portal</CwaChannel>
<CwaOrderType>UT Redemption</CwaOrderType>
<ListOfOrderEntry-LineItems>
<OrderEntry-LineItems>
<CwaLineTotalAmount2>1000</CwaLineTotalAmount2>
<CwaProductCode>005</CwaProductCode>
</OrderEntry-LineItems>
</ListOfOrderEntry-LineItems>
</OrderEntry-Orders>
这是我的 BIP 代码:
<?for-each-group: OrderEntry-LineItems; CwaProductCode?>
<?if:../../CwaOrderType='UT Sales' and ../../CwaChannel='Customer Portal'?>
<?for-each: current-group()?>
<?CwaProductCode?>
<?xdoxslt:set_variable($_XDOCTX, 'countFund', xdoxslt:get_variable($_XDOCTX, 'countFund')+1)?>
<?xdoxslt:set_variable($_XDOCTX, 'TotalCount', xdoxslt:get_variable($_XDOCTX, 'TotalCount')+1)?>
<?xdoxslt:get_variable($_XDOCTX, 'countFund')?>
<?xdoxslt:set_variable($_XDOCTX, 'countFund', 0)?>
<?end if?>
<?end for-each-group?>
<?xdoxslt:get_variable($_XDOCTX, 'TotalCount')?>
但是出来的结果好像没有if条件。 例如,CwaProductCode 将显示正确的结果,但它会将所有内容一起计算,就好像根本没有过滤一样。
不确定哪里出错了。
进行分组后,访问该分组上方的任何父级 returns 不明确数据。它可能总是指向第一个 'OrderEntry-Orders' 节点。如果更改 xml.
中元素的顺序,您会看到这一点如果您的要求是仅对具有 CwaOrderType='UT Sales' 和 .CwaChannel='Customer Portal' 的那些 'OrderEntry-LineItems' 节点进行分组,您可以像这样在分组中赋予该过滤器:
<?for-each-group: OrderEntry-LineItems[../../CwaOrderType='UT Sales' and ../../CwaChannel='Customer Portal']; CwaProductCode?>
试试这个代码:
<?for-each-group: OrderEntry-LineItems[../../CwaOrderType='UT Sales' and ../../CwaChannel='Customer Portal']; CwaProductCode?>
<?for-each: current-group()?>
<?CwaProductCode?>
<?xdoxslt:set_variable($_XDOCTX, 'countFund', xdoxslt:get_variable($_XDOCTX, 'countFund')+1)?>
<?xdoxslt:set_variable($_XDOCTX, 'TotalCount', xdoxslt:get_variable($_XDOCTX, 'TotalCount')+1)?>
<?xdoxslt:get_variable($_XDOCTX, 'countFund')?>
<?xdoxslt:set_variable($_XDOCTX, 'countFund', 0)?>
<?end for-each-group?>
<?xdoxslt:get_variable($_XDOCTX, 'TotalCount')?>
给出这个结果:
001
1
1
005
1
005
1
3
<?for-each-group: OrderEntry-LineItems[../../CwaOrderType='UT Sales' and ../../CwaChannel='Customer Portal']; CwaProductCode?>
<?CwaProductCode?>
<?count(current-group()/.)?>
<?xdoxslt:set_variable($_XDOCTX, 'TotalCount', xdoxslt:get_variable($_XDOCTX, 'TotalCount')+ count(current-group()/.))?>
<?end for-each-group?>
<?xdoxslt:get_variable($_XDOCTX, 'TotalCount')?>
给予
001
1
005
2
3