【发布时间】:2023-01-13 13:05:22
【问题描述】:
我有一个使用 XML 数据源的报告 (.rdl) 文件。 XML 节点之一是我需要在报告中显示的“税”。但是,如果 XML 数据集中存在另一个值,我需要使用 get 并显示不同节点的 Tax 值。这是 XML 数据源的最小化版本。
<Query>
<XmlData><?xml version="1.0" encoding="us-ascii"?>
<Customer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CustomerName>Customer Name</CustomerName>
<Invoices>
<Invoice>
<CustomerId>12345</CustomerId>
<Tax>0.56</Tax>
<parts>
<part>
<Category>Category1</Category>
<Items>
<Item>
<ItemDescription>OtherItem1</ItemDescription>
<ItemTotal>0.79</ItemTotal>
</Item>
<Item>
<ItemDescription>NewSalesTax</ItemDescription>
<ItemTotal>0.99</ItemTotal>
</Item>
<Item>
<ItemDescription>OtherItem2</ItemDescription>
<ItemTotal>0.59</ItemTotal>
</Item>
</Items>
</part>
</parts>
</Invoice>
</Invoices>
</Customer>
在上面的 XML 中,如果 ItemDescription 节点存在“NewSalesTax”值,我需要为 Tax 值显示 ItemTotal 节点的相应值。 (即 0.99)
我可以使用 SUM 函数检查节点是否存在:
=SUM(iif(Fields!ItemDescription.Value="NewSalesTax",1,0))
但是我不确定如果找到相应的 ItemTotal 值如何定位。另请注意,我不能依赖 Item 在 Items Group 中的特定位置。它可以存在,不存在,第一个,最后一个或在组的中间。
【问题讨论】:
标签: xml reporting-services datasource reportbuilder rdl