<?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 How to simulate sql minus via set analyis? in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/How-to-simulate-sql-minus-via-set-analyis/m-p/1871189#M71899</link>
    <description>&lt;P&gt;I would like to be able to accomplish this within a qlik sense table, not the load script if possible.&lt;/P&gt;
&lt;P&gt;I have two tables with this general structure.&lt;/P&gt;
&lt;P&gt;Orders: Primary Key OID&lt;/P&gt;
&lt;TABLE border="1" width="44.44444609851372%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;OID(string)&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;customerID (string)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;1|1&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;acmenorth&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="28px"&gt;1|2&lt;/TD&gt;
&lt;TD height="28px"&gt;apertureeast&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;items: Primary Key itemID&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;itemID (string)&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;OID (string)&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;inputDate (string)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;1|1&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;1|1&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;20211214&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;1|2&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;1|2&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;
&lt;P&gt;20211210&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2|1&lt;/TD&gt;
&lt;TD&gt;1|1&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;20211109&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An order will always have one or more items, so a one to many relationship. Due to the implicit foreign key relationship, I have a synthetic key using OID to relate the tables in qlik sense.&lt;/P&gt;
&lt;P&gt;I would like to create a table that subtracts the list of distinct customerIDs in the current month's items vs the previous month. In this case, December vs November. My overall goal is to be able to see what customerIDs have items in the current month that weren't in the previous month.&lt;/P&gt;
&lt;P&gt;If I were to do this in sql to this example dataset, I would expect only apertureeast to be returned, as the other customer had an item in November.&lt;BR /&gt;&lt;BR /&gt;I've tried two different methods.&lt;BR /&gt;1.&lt;BR /&gt;Measure: &lt;BR /&gt;count( {$&amp;lt;customerID= E({1&amp;lt;[inputDate.autoCalendar.YearMonth]={'2021-Nov'}&amp;gt;}), [inputDate.autoCalendar.YearMonth]={'2021-Dec'}&amp;gt;} [itemID])&lt;/P&gt;
&lt;P&gt;Dimension:&lt;/P&gt;
&lt;P&gt;customerID&lt;BR /&gt;&lt;BR /&gt;2.&lt;/P&gt;
&lt;P&gt;Measure: &lt;BR /&gt;count( {&amp;lt;[inputDate.autoCalendar.YearMonth]={'2021-Dec'}&amp;gt; - &amp;lt;[inputDate.autoCalendar.YearMonth]={'2021-Oct'}&amp;gt; } itemID)&lt;/P&gt;
&lt;P&gt;Dimension:&lt;/P&gt;
&lt;P&gt;customerID&lt;BR /&gt;&lt;BR /&gt;Neither seem to be getting me what I want. In the load script I've set the&amp;nbsp;DateFormat='YYYYMMDD'. I've used the autocalendar pre-generated script to convert it into the ym field that is seen in my examples. I've tried&amp;nbsp; using inputDate = {'202112*'} for example, but I've found using the autocalendar field tends to work better.&lt;BR /&gt;&lt;BR /&gt;Any suggestions would be appreciated! Thank you.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Dec 2021 23:02:59 GMT</pubDate>
    <dc:creator>cj3651</dc:creator>
    <dc:date>2021-12-14T23:02:59Z</dc:date>
    <item>
      <title>How to simulate sql minus via set analyis?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-simulate-sql-minus-via-set-analyis/m-p/1871189#M71899</link>
      <description>&lt;P&gt;I would like to be able to accomplish this within a qlik sense table, not the load script if possible.&lt;/P&gt;
&lt;P&gt;I have two tables with this general structure.&lt;/P&gt;
&lt;P&gt;Orders: Primary Key OID&lt;/P&gt;
&lt;TABLE border="1" width="44.44444609851372%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;OID(string)&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;customerID (string)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;1|1&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;acmenorth&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="28px"&gt;1|2&lt;/TD&gt;
&lt;TD height="28px"&gt;apertureeast&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;items: Primary Key itemID&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;itemID (string)&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;OID (string)&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;inputDate (string)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;1|1&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;1|1&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;20211214&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;1|2&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;1|2&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;
&lt;P&gt;20211210&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2|1&lt;/TD&gt;
&lt;TD&gt;1|1&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;20211109&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An order will always have one or more items, so a one to many relationship. Due to the implicit foreign key relationship, I have a synthetic key using OID to relate the tables in qlik sense.&lt;/P&gt;
&lt;P&gt;I would like to create a table that subtracts the list of distinct customerIDs in the current month's items vs the previous month. In this case, December vs November. My overall goal is to be able to see what customerIDs have items in the current month that weren't in the previous month.&lt;/P&gt;
&lt;P&gt;If I were to do this in sql to this example dataset, I would expect only apertureeast to be returned, as the other customer had an item in November.&lt;BR /&gt;&lt;BR /&gt;I've tried two different methods.&lt;BR /&gt;1.&lt;BR /&gt;Measure: &lt;BR /&gt;count( {$&amp;lt;customerID= E({1&amp;lt;[inputDate.autoCalendar.YearMonth]={'2021-Nov'}&amp;gt;}), [inputDate.autoCalendar.YearMonth]={'2021-Dec'}&amp;gt;} [itemID])&lt;/P&gt;
&lt;P&gt;Dimension:&lt;/P&gt;
&lt;P&gt;customerID&lt;BR /&gt;&lt;BR /&gt;2.&lt;/P&gt;
&lt;P&gt;Measure: &lt;BR /&gt;count( {&amp;lt;[inputDate.autoCalendar.YearMonth]={'2021-Dec'}&amp;gt; - &amp;lt;[inputDate.autoCalendar.YearMonth]={'2021-Oct'}&amp;gt; } itemID)&lt;/P&gt;
&lt;P&gt;Dimension:&lt;/P&gt;
&lt;P&gt;customerID&lt;BR /&gt;&lt;BR /&gt;Neither seem to be getting me what I want. In the load script I've set the&amp;nbsp;DateFormat='YYYYMMDD'. I've used the autocalendar pre-generated script to convert it into the ym field that is seen in my examples. I've tried&amp;nbsp; using inputDate = {'202112*'} for example, but I've found using the autocalendar field tends to work better.&lt;BR /&gt;&lt;BR /&gt;Any suggestions would be appreciated! Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 23:02:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-simulate-sql-minus-via-set-analyis/m-p/1871189#M71899</guid>
      <dc:creator>cj3651</dc:creator>
      <dc:date>2021-12-14T23:02:59Z</dc:date>
    </item>
  </channel>
</rss>

