<?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 Calculated Dimension Comparing Dates Using Set Analysis in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Calculated-Dimension-Comparing-Dates-Using-Set-Analysis/m-p/1258350#M25571</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an expression that's not working as intended - was hoping someone could shed some light please:&lt;/P&gt;&lt;P&gt;This is in a straight table, and it's intended to show results in 2 scenarios&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a)&amp;nbsp; when a date is selected, show data where the VerifiedDate = the date selected (ReferenceDate)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b)&amp;nbsp; if no date is selected, show data where the VerifiedDate = today's date ($(vLoad)&lt;/P&gt;&lt;P&gt;In either scenario, the resulting rows should be ids selected from the VerifiedDate being compared to 1 date only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if(GetSelectedCount(ReferenceDate)=1, aggr(Only({$&amp;lt;$(vDim).VerifiedDate={"&amp;gt;=ReferenceDate"}&amp;gt;}$(vDim).id),$(vDim).id), aggr(Only({$&amp;lt;$(vDim).VerifiedDate={'$(=vLoad)'}&amp;gt;}$(vDim).id),$(vDim).id))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I split it out, the last condition works.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;aggr(Only({$&amp;lt;$(vDim).VerifiedDate={'$(=vLoad)'}&amp;gt;}$(vDim).id),$(vDim).id)&amp;nbsp; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/SPAN&gt;&amp;nbsp; //$(vLoad) is a variable pulled from load script of current date&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;If I use the first condition, it does not, however - produces incorrect values.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;aggr(Only({$&amp;lt;$(vDim).VerifiedDate={"&amp;gt;=ReferenceDate"}&amp;gt;}$(vDim).id),$(vDim).id) &lt;/STRONG&gt;&lt;/SPAN&gt; //ReferenceDate is a date field.&amp;nbsp; Format verified.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;I'm pretty sure my issue lies in here&amp;nbsp; &lt;SPAN style="font-size: 13.3333px;"&gt;{"&amp;gt;=ReferenceDate"}&amp;nbsp; but I ran out of combinations to try.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Thoughts?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Dec 2016 06:10:27 GMT</pubDate>
    <dc:creator>joey_lutes</dc:creator>
    <dc:date>2016-12-14T06:10:27Z</dc:date>
    <item>
      <title>Calculated Dimension Comparing Dates Using Set Analysis</title>
      <link>https://community.qlik.com/t5/App-Development/Calculated-Dimension-Comparing-Dates-Using-Set-Analysis/m-p/1258350#M25571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an expression that's not working as intended - was hoping someone could shed some light please:&lt;/P&gt;&lt;P&gt;This is in a straight table, and it's intended to show results in 2 scenarios&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a)&amp;nbsp; when a date is selected, show data where the VerifiedDate = the date selected (ReferenceDate)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b)&amp;nbsp; if no date is selected, show data where the VerifiedDate = today's date ($(vLoad)&lt;/P&gt;&lt;P&gt;In either scenario, the resulting rows should be ids selected from the VerifiedDate being compared to 1 date only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if(GetSelectedCount(ReferenceDate)=1, aggr(Only({$&amp;lt;$(vDim).VerifiedDate={"&amp;gt;=ReferenceDate"}&amp;gt;}$(vDim).id),$(vDim).id), aggr(Only({$&amp;lt;$(vDim).VerifiedDate={'$(=vLoad)'}&amp;gt;}$(vDim).id),$(vDim).id))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I split it out, the last condition works.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;aggr(Only({$&amp;lt;$(vDim).VerifiedDate={'$(=vLoad)'}&amp;gt;}$(vDim).id),$(vDim).id)&amp;nbsp; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/SPAN&gt;&amp;nbsp; //$(vLoad) is a variable pulled from load script of current date&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;If I use the first condition, it does not, however - produces incorrect values.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;aggr(Only({$&amp;lt;$(vDim).VerifiedDate={"&amp;gt;=ReferenceDate"}&amp;gt;}$(vDim).id),$(vDim).id) &lt;/STRONG&gt;&lt;/SPAN&gt; //ReferenceDate is a date field.&amp;nbsp; Format verified.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;I'm pretty sure my issue lies in here&amp;nbsp; &lt;SPAN style="font-size: 13.3333px;"&gt;{"&amp;gt;=ReferenceDate"}&amp;nbsp; but I ran out of combinations to try.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Thoughts?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Dec 2016 06:10:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculated-Dimension-Comparing-Dates-Using-Set-Analysis/m-p/1258350#M25571</guid>
      <dc:creator>joey_lutes</dc:creator>
      <dc:date>2016-12-14T06:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated Dimension Comparing Dates Using Set Analysis</title>
      <link>https://community.qlik.com/t5/App-Development/Calculated-Dimension-Comparing-Dates-Using-Set-Analysis/m-p/1258351#M25572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I'm getting closer.&amp;nbsp; The original statement I posted isn't quite accurate.&amp;nbsp; The correct statement is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if(GetSelectedCount(ReferenceDate)=1, aggr(Only({$&amp;lt;$(vDim).VerifiedDate={"&amp;gt;=$(=ReferenceDate)"}, $(vDim).AddedDate={"&amp;lt;=$(=ReferenceDate)"}&amp;gt;}$(vDim).id),$(vDim).id), aggr(Only({$&amp;lt;$(vDim).VerifiedDate={'$(=vLoad)'}&amp;gt;}$(vDim).id),$(vDim).id))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've verified that the individual components of the 'if' statement both produce correct results now:&lt;/P&gt;&lt;P&gt;If a date is selected,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;aggr(Only({$&amp;lt;$(vDim).VerifiedDate={"&amp;gt;=$(=ReferenceDate)"}, $(vDim).AddedDate={"&amp;lt;=$(=ReferenceDate)"}&amp;gt;}$(vDim).id),$(vDim).id) &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;does indeed produce intended rows, regardless of ReferenceDate selected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If no date is selected,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;aggr(Only({$&amp;lt;$(vDim).VerifiedDate={'$(=vLoad)'}&amp;gt;}$(vDim).id),$(vDim).id)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;also produces intended rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, when I put the two in an 'if' statement, it stops working IF any date except the first one is selected.&amp;nbsp; The 'else' portion is functioning.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ANY ideas as to why I might be seeing that behavior?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2016 15:54:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculated-Dimension-Comparing-Dates-Using-Set-Analysis/m-p/1258351#M25572</guid>
      <dc:creator>joey_lutes</dc:creator>
      <dc:date>2016-12-15T15:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated Dimension Comparing Dates Using Set Analysis</title>
      <link>https://community.qlik.com/t5/App-Development/Calculated-Dimension-Comparing-Dates-Using-Set-Analysis/m-p/1258352#M25573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure why you need Aggr() here, can you try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;if(GetSelectedCount(ReferenceDate)=1, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Only({$&amp;lt;$(vDim).VerifiedDate={"&amp;gt;=$(=ReferenceDate)"}, $(vDim).AddedDate={"&amp;lt;=$(=ReferenceDate)"}&amp;gt;}$(vDim).id), &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Only({$&amp;lt;$(vDim).VerifiedDate={'$(=vLoad)'}&amp;gt;}$(vDim).id))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or this if you need your Aggr()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;if(GetSelectedCount(ReferenceDate)=1, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Only(&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;{$&amp;lt;$(vDim).VerifiedDate={"&amp;gt;=$(=ReferenceDate)"}, $(vDim).AddedDate={"&amp;lt;=$(=ReferenceDate)"}&amp;gt;} &lt;/STRONG&gt;aggr(Only({$&amp;lt;$(vDim).VerifiedDate={"&amp;gt;=$(=ReferenceDate)"}, $(vDim).AddedDate={"&amp;lt;=$(=ReferenceDate)"}&amp;gt;}$(vDim).id),$(vDim).id)), &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Only(&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;{$&amp;lt;$(vDim).VerifiedDate={'$(=vLoad)'}&amp;gt;} &lt;/STRONG&gt;aggr(Only({$&amp;lt;$(vDim).VerifiedDate={'$(=vLoad)'}&amp;gt;}$(vDim).id),$(vDim).id)))&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2016 16:52:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculated-Dimension-Comparing-Dates-Using-Set-Analysis/m-p/1258352#M25573</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-12-15T16:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated Dimension Comparing Dates Using Set Analysis</title>
      <link>https://community.qlik.com/t5/App-Development/Calculated-Dimension-Comparing-Dates-Using-Set-Analysis/m-p/1258353#M25574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The only reason I had AGGR in there was because I couldn't get ONLY to work on its own.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did try both snippets, and both produced 'Invalid Dimension' errors.&amp;nbsp; I don't see any glaring issues there.&lt;/P&gt;&lt;P&gt;So I can try each of the conditions independently.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I separate them out and try the ONLY conditions on their own, each produces the same 'Invalid Dimension' error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Joey&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2016 17:05:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculated-Dimension-Comparing-Dates-Using-Set-Analysis/m-p/1258353#M25574</guid>
      <dc:creator>joey_lutes</dc:creator>
      <dc:date>2016-12-15T17:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated Dimension Comparing Dates Using Set Analysis</title>
      <link>https://community.qlik.com/t5/App-Development/Calculated-Dimension-Comparing-Dates-Using-Set-Analysis/m-p/1258354#M25575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I've resorted to using a nested 'if' statement.&amp;nbsp; I've decided it must be a bug in Qlik's code - because both conditions work perfectly on their own, and when combined the results are wonky.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(GetSelectedCount(ReferenceDate)=1,&lt;/P&gt;&lt;P&gt;if([$(vDim).VerifiedDate]&amp;gt;= ReferenceDate and [$(vDim).AddedDate] &amp;lt;= ReferenceDate, [$(vDim).id]),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aggr(Only({$&amp;lt;$(vDim).VerifiedDate={'$(=vLoad)'}&amp;gt;}$(vDim).id),$(vDim).id))&lt;/P&gt;&lt;P&gt;This is functional for now and at least buy me time to troubleshoot more and report it.&lt;/P&gt;&lt;P&gt;Calculated Dimensions should NOT be made this complicated.&amp;nbsp; Standard expressions should be allowed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Weird stuff,&amp;nbsp; Maynard.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2016 20:56:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculated-Dimension-Comparing-Dates-Using-Set-Analysis/m-p/1258354#M25575</guid>
      <dc:creator>joey_lutes</dc:creator>
      <dc:date>2016-12-15T20:56:57Z</dc:date>
    </item>
  </channel>
</rss>

