简体   繁体   中英

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. 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. I've total 10 records but they are not being shown or the report preivew show 0 records. 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.

2.If you write SQL query, transform it to fetchxml using Kingswaysoft sql2fetchxml free online converter.

3.Read this article to transform fetchxml into Adv find query.

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

*work for multiple values

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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