简体   繁体   English

如何在基于 Fetchxml 的报告中的“或”过滤器中使用“in”运算符?

[英]How to use 'in' operator in 'or' filter in Fetchxml based report?

I am using following xml in an Fetch based report in SSRS for Dynamics 365. I've allowed @transaction parameter to null but rest of the both parameters must have values.我在 SSRS for Dynamics 365 的基于 Fetch 的报告中使用以下 xml。我已允许@transaction参数为空,但其余两个参数必须具有值。 So, I put an or condition so that if @transaction is null or 0 then on the base of 1 and 2 grab the orders.因此,我设置了一个 or 条件,以便如果@transaction为 null 或 0,则在 1 和 2 的基础上获取订单。 I've total 10 records but they are not being shown or the report preivew show 0 records.我总共有 10 条记录,但它们没有显示或报告 preivew 显示 0 条记录。 Any idea how to resolve this?知道如何解决这个问题吗?

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
      <entity name="salesorder">
        <attribute name="salesorderid" />
        <attribute name="ordernumber" />
        <order attribute="ordernumber" descending="true" />
        <filter type="and">
          <condition attribute="new_transaction" operator="eq" value="@transaction" />
          <condition attribute="createdon" operator="on-or-before" value="@To" />
          <condition attribute="createdon" operator="on-or-after" value="@From" />
        </filter>
        <filter type="or">
            <condition attribute="new_transaction" operator="in" >
                <value>1</value>
                <value>2</value>
            </condition>
          </filter>
      </entity>
    </fetch>

If I understood correctly, you can replace your filter like below to get result.如果我理解正确,您可以像下面这样更换过滤器以获得结果。

<filter type="and">
   <condition attribute="createdon" operator="on-or-before" value="@To" />
   <condition attribute="createdon" operator="on-or-after" value="@From" />
   <filter type="or">    
        <condition attribute="new_transaction" operator="in" >
            <value>1</value>
            <value>2</value>
        </condition>
        <condition attribute="new_transaction" operator="eq" value="@transaction" />
   </filter>
</filter>

Pro tips:专业提示:
1.Build the query in Advanced find, test the result & Download fetchxml from there to use in report. 1.在高级查找中构建查询,测试结果并从那里下载 fetchxml 以在报告中使用。

2.If you write SQL query, transform it to fetchxml using Kingswaysoft sql2fetchxml free online converter. 2.如果你写SQL查询,使用Kingswaysoft sql2fetchxml免费在线转换器将其转换为fetchxml。

3.Read this article to transform fetchxml into Adv find query. 3.阅读本文将fetchxml转换为Adv find查询。

<filter type="or">
  <condition attribute="new_transaction" operator="in" value=@parm>
  </condition>
</filter>

*work for multiple values *为多个值工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM