<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Complex filter in Loop XPath query in tExtractJSONField in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Complex-filter-in-Loop-XPath-query-in-tExtractJSONField/m-p/2290271#M63568</link>
    <description>&lt;P&gt;Hi, I am able to do simple filtering in the&amp;nbsp;Loop XPath query in a tExtractJsonField component.&amp;nbsp; For example, if my input JSON string is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;[
&amp;nbsp;{
&amp;nbsp; &amp;nbsp;"snack": {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"name": "Apple",
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "id": 1,
 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"type": "Fruit"
&amp;nbsp; &amp;nbsp;}
&amp;nbsp;},
&amp;nbsp;{
&amp;nbsp; &amp;nbsp;"snack": {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"name": "Orange",
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"id": 2,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"type": "Fruit"
&amp;nbsp; &amp;nbsp;}
&amp;nbsp;},
&amp;nbsp;{
&amp;nbsp; &amp;nbsp;"snack": {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"name": "Broccoli",
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"id": 3,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"type": "Vegetable"
&amp;nbsp; &amp;nbsp;}
&amp;nbsp;}
]&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can use this&amp;nbsp;Loop XPath query with a simple filter to return only the fruit snacks:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;"/snack[type="Fruit"]"&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to do something a little more complex.&amp;nbsp; I want to select the Apple if the count of vegetables is &amp;lt;=1, else I want to select the Orange.&amp;nbsp; I tried adding more complex xpath using the count() function but could not get it to work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;"/snack[type="Fruit" and (&lt;BR /&gt;(name ="Apple" and count(/snack/type="Vegetable") &amp;lt;= 1) or &lt;BR /&gt;(name ="Orange" and count(/snack/type="Vegetable") &amp;gt; 1))]"&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are these more complex filters even supported in Talend?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance for any help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 May 2019 22:11:20 GMT</pubDate>
    <dc:creator>nfz11</dc:creator>
    <dc:date>2019-05-02T22:11:20Z</dc:date>
    <item>
      <title>Complex filter in Loop XPath query in tExtractJSONField</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-filter-in-Loop-XPath-query-in-tExtractJSONField/m-p/2290271#M63568</link>
      <description>&lt;P&gt;Hi, I am able to do simple filtering in the&amp;nbsp;Loop XPath query in a tExtractJsonField component.&amp;nbsp; For example, if my input JSON string is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;[
&amp;nbsp;{
&amp;nbsp; &amp;nbsp;"snack": {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"name": "Apple",
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "id": 1,
 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"type": "Fruit"
&amp;nbsp; &amp;nbsp;}
&amp;nbsp;},
&amp;nbsp;{
&amp;nbsp; &amp;nbsp;"snack": {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"name": "Orange",
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"id": 2,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"type": "Fruit"
&amp;nbsp; &amp;nbsp;}
&amp;nbsp;},
&amp;nbsp;{
&amp;nbsp; &amp;nbsp;"snack": {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"name": "Broccoli",
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"id": 3,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"type": "Vegetable"
&amp;nbsp; &amp;nbsp;}
&amp;nbsp;}
]&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can use this&amp;nbsp;Loop XPath query with a simple filter to return only the fruit snacks:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;"/snack[type="Fruit"]"&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to do something a little more complex.&amp;nbsp; I want to select the Apple if the count of vegetables is &amp;lt;=1, else I want to select the Orange.&amp;nbsp; I tried adding more complex xpath using the count() function but could not get it to work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;"/snack[type="Fruit" and (&lt;BR /&gt;(name ="Apple" and count(/snack/type="Vegetable") &amp;lt;= 1) or &lt;BR /&gt;(name ="Orange" and count(/snack/type="Vegetable") &amp;gt; 1))]"&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are these more complex filters even supported in Talend?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance for any help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2019 22:11:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-filter-in-Loop-XPath-query-in-tExtractJSONField/m-p/2290271#M63568</guid>
      <dc:creator>nfz11</dc:creator>
      <dc:date>2019-05-02T22:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: Complex filter in Loop XPath query in tExtractJSONField</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-filter-in-Loop-XPath-query-in-tExtractJSONField/m-p/2290272#M63569</link>
      <description>&lt;P&gt;I figured it out.&amp;nbsp; You can use complex filters like the one I describe.&amp;nbsp; The exact syntax would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;"/snack[type="Fruit"][&lt;BR /&gt;(name ="Apple" and count(//type[text()='Vegetable']) &amp;lt;= 1) or &lt;BR /&gt;(name ="Orange" and count(//type[text()='Vegetable']) &amp;gt; 1)]"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2019 23:11:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-filter-in-Loop-XPath-query-in-tExtractJSONField/m-p/2290272#M63569</guid>
      <dc:creator>nfz11</dc:creator>
      <dc:date>2019-05-02T23:11:45Z</dc:date>
    </item>
  </channel>
</rss>

