<?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 Using Date Variables in Set Analysis in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320981#M118251</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a set analysis expression with two variable, Date, and Forecast.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;﻿﻿=sum({&amp;lt;Date={'7/31/2011'}, Forecast={'Actual'}&amp;gt;}AvgBalance)&lt;/P&gt;&lt;P&gt;﻿&lt;/P&gt;&lt;P&gt;I am trying to use a more flexible expression for the Date variable.&amp;nbsp; Essentiall I want the date to be the most recent with an Actual value. &lt;/P&gt;&lt;P&gt;I have tried using a sql select statement to create a new variable named CurrentDate in the load:&lt;/P&gt;&lt;P&gt;﻿&lt;BR /&gt;sql select MAX(date) as CurrentDate from graph_data where Forecast = 'actual';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works fine and the value of CurrentDate is correct.&amp;nbsp; But when I try to add this new variable to the set analysis, it doesn't work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;﻿﻿﻿﻿﻿﻿﻿﻿﻿=sum({&amp;lt;Date=CurrentDate, Forecast={'Actual'}&amp;gt;}AvgBalance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this possible?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have also tried to get a date based off of today() function.&amp;nbsp; Using Date(MonthEnd(Today(), -1)'MM/DD/YYYY') I can a date I can live with.&lt;/P&gt;&lt;P&gt;However if I substitute this expression into the set analysis for '7/31/2011' it will not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=sum({Date={'(MonthEnd(Today(),-1)'MM/DD/YYYY')}, Forecast={'Actual'}&amp;gt;}AvgBalance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In reading past posts this may not be working due to MonthEnd() adding time onto the value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I try a if(CurrentDate = Date, 'True', 'False') or substitute the expression above for CurrentDate I do get a True value for Date 7/31/2011, so they do equal in this expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any Advice?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Sep 2011 15:57:40 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-09-02T15:57:40Z</dc:date>
    <item>
      <title>Using Date Variables in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320981#M118251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a set analysis expression with two variable, Date, and Forecast.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;﻿﻿=sum({&amp;lt;Date={'7/31/2011'}, Forecast={'Actual'}&amp;gt;}AvgBalance)&lt;/P&gt;&lt;P&gt;﻿&lt;/P&gt;&lt;P&gt;I am trying to use a more flexible expression for the Date variable.&amp;nbsp; Essentiall I want the date to be the most recent with an Actual value. &lt;/P&gt;&lt;P&gt;I have tried using a sql select statement to create a new variable named CurrentDate in the load:&lt;/P&gt;&lt;P&gt;﻿&lt;BR /&gt;sql select MAX(date) as CurrentDate from graph_data where Forecast = 'actual';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works fine and the value of CurrentDate is correct.&amp;nbsp; But when I try to add this new variable to the set analysis, it doesn't work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;﻿﻿﻿﻿﻿﻿﻿﻿﻿=sum({&amp;lt;Date=CurrentDate, Forecast={'Actual'}&amp;gt;}AvgBalance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this possible?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have also tried to get a date based off of today() function.&amp;nbsp; Using Date(MonthEnd(Today(), -1)'MM/DD/YYYY') I can a date I can live with.&lt;/P&gt;&lt;P&gt;However if I substitute this expression into the set analysis for '7/31/2011' it will not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=sum({Date={'(MonthEnd(Today(),-1)'MM/DD/YYYY')}, Forecast={'Actual'}&amp;gt;}AvgBalance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In reading past posts this may not be working due to MonthEnd() adding time onto the value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I try a if(CurrentDate = Date, 'True', 'False') or substitute the expression above for CurrentDate I do get a True value for Date 7/31/2011, so they do equal in this expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any Advice?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Sep 2011 15:57:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320981#M118251</guid>
      <dc:creator />
      <dc:date>2011-09-02T15:57:40Z</dc:date>
    </item>
    <item>
      <title>Using Date Variables in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320982#M118252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have 2 suggestions:&lt;/P&gt;&lt;P&gt;1) if you wanna use a variable, try setting document varibla, not loading a field in the script. like this:&lt;/P&gt;&lt;P&gt;CurrentDate = max({1} Date)&lt;/P&gt;&lt;P&gt;then you can try this in your expression:&lt;/P&gt;&lt;P&gt;sum({&amp;lt;Date=$(CurrentDate), Forecast={'Actual'}&amp;gt;}AvgBalance)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2)if you wanna use the "monthend" way, you can try using the floor() function, this should completly eliminate the time from the date:&lt;/P&gt;&lt;P&gt;=sum({Date={floor((MonthEnd(Today(),-1))}, Forecast={'Actual'}&amp;gt;}AvgBalance)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Sep 2011 16:05:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320982#M118252</guid>
      <dc:creator>lucas4bi</dc:creator>
      <dc:date>2011-09-02T16:05:55Z</dc:date>
    </item>
    <item>
      <title>Using Date Variables in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320983#M118253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the response, but I couldn't get either suggestion to work.&amp;nbsp; &lt;/P&gt;&lt;P&gt;I copied in CurrentDate = max({1} Date) in to the qlikview load statement and it errored out on reload.&amp;nbsp; &lt;/P&gt;&lt;P&gt;I also tried the floor statement, but the expression builder has an issue with the { before floor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I may be forgetting something, I am still very new to this.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Sep 2011 17:55:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320983#M118253</guid>
      <dc:creator />
      <dc:date>2011-09-02T17:55:50Z</dc:date>
    </item>
    <item>
      <title>Using Date Variables in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320984#M118254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's because you dont have to set that variable in a script, but you should just set a document variable.&lt;/P&gt;&lt;P&gt;If you go on "Settings" you will see "Variable Overview", there you can set a document variable, which you can use in your set analisys expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me now&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Sep 2011 07:40:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320984#M118254</guid>
      <dc:creator>lucas4bi</dc:creator>
      <dc:date>2011-09-05T07:40:21Z</dc:date>
    </item>
    <item>
      <title>Using Date Variables in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320985#M118255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was able to create an expression that returns the correct date I am looking for:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=max({&amp;lt;Forecast={'Actual'}&amp;gt;}Date)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I created a document variable CurrentDate and defined it with the above expression.&lt;/P&gt;&lt;P&gt;But when I try to add the variable in the set analysis expression&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=sum({&amp;lt;Date={CurrentDate}, Forecast={'Actual'}&amp;gt;}AvgBalance)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It does not work.&amp;nbsp; Am I plugging CurrentDate in correctly?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Sep 2011 15:59:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320985#M118255</guid>
      <dc:creator />
      <dc:date>2011-09-06T15:59:36Z</dc:date>
    </item>
    <item>
      <title>Using Date Variables in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320986#M118256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you write the variable like this:&amp;nbsp; $(CurrentDate)&lt;/P&gt;&lt;P&gt;try with that &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Sep 2011 09:32:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320986#M118256</guid>
      <dc:creator>lucas4bi</dc:creator>
      <dc:date>2011-09-07T09:32:08Z</dc:date>
    </item>
    <item>
      <title>Using Date Variables in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320987#M118257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Worked.&amp;nbsp; Thanks, I appreciate all of the help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea on how I can now create another variable for the previous month.&lt;/P&gt;&lt;P&gt;So if ﻿﻿=max({&amp;lt;Forecast={'Actual'}&amp;gt;}Date) returns 07/31/2011&lt;/P&gt;&lt;P&gt;I need to now get 06/30/2011&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Sep 2011 19:07:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320987#M118257</guid>
      <dc:creator />
      <dc:date>2011-09-07T19:07:30Z</dc:date>
    </item>
    <item>
      <title>Using Date Variables in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320988#M118258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Give a look at the function monthend()&lt;/P&gt;&lt;P&gt;that can help you doing what you need setting the right parameters&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Sep 2011 16:18:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320988#M118258</guid>
      <dc:creator>lucas4bi</dc:creator>
      <dc:date>2011-09-08T16:18:01Z</dc:date>
    </item>
    <item>
      <title>Using Date Variables in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320989#M118259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; I have been able to create another variable based on either:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=Date(MonthEnd('$CurrentDate)',-1,'MM/DD/YYYY')&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;=﻿﻿Date(AddMonths('$CurrentDate)',-1)'MM/DD/YYYY')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;both of which give a value of 6/30/2011&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But if I use this variable in a set analysis express as I did with the first variable I don't get a value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so =sum({&amp;lt;Date={'$(PreviousDate)'),Forecast={'Actual'}&amp;gt;}AvgBalance gives me a value of 0&lt;/P&gt;&lt;P&gt;but =sum({&amp;lt;Date={'$(CurrentDate)'},Forecast={'Actual'}&amp;gt;}AvgBalance gives me a real value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought that maybe using a variable inside another variable could cause problems, so I replaced the '$CurrentDate' in the variable definition with CurrentDate's equation.&amp;nbsp; That still returned the proper value for the PreviousDate variable, but once used in an expression it returns the same 0 value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Sep 2011 18:07:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320989#M118259</guid>
      <dc:creator />
      <dc:date>2011-09-08T18:07:22Z</dc:date>
    </item>
    <item>
      <title>Using Date Variables in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320990#M118260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Figured it out, looks like it didn't like the MM/DD/YYYY format, had to be M/DD/YYYY.&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Sep 2011 18:36:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320990#M118260</guid>
      <dc:creator />
      <dc:date>2011-09-08T18:36:05Z</dc:date>
    </item>
    <item>
      <title>Using Date Variables in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320991#M118261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; I can't seem to get the Today function to work inside a Set statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following statement, which works fine if I hard code an actual date in it, but I want to show a rolling 10 weeks of data in my chart.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;=avg({$&amp;lt;[MI Date]={'&amp;gt;=today()-70'}&amp;gt;}[DS_TotalScore]) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anyone can tell me where I'm going wrong, I would greatly appreciate it!&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Sep 2011 15:00:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320991#M118261</guid>
      <dc:creator />
      <dc:date>2011-09-30T15:00:18Z</dc:date>
    </item>
    <item>
      <title>Using Date Variables in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320992#M118262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try&lt;BR /&gt;={"&amp;gt;=$(=Today())"} &amp;gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gabriel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Sep 2011 15:02:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320992#M118262</guid>
      <dc:creator>GabrielAraya</dc:creator>
      <dc:date>2011-09-30T15:02:39Z</dc:date>
    </item>
    <item>
      <title>Using Date Variables in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320993#M118263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks Gabriel...I can get there to work, but it doesn't work when I put in -70 in the forumla to look back 70 days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's what I have now:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;=avg({$&amp;lt;[MI Date]={"&amp;gt;=$(=Today()-70)"} &amp;gt;}[DS_TotalScore]) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Do you see anything wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Sep 2011 15:26:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Date-Variables-in-Set-Analysis/m-p/320993#M118263</guid>
      <dc:creator />
      <dc:date>2011-09-30T15:26:25Z</dc:date>
    </item>
  </channel>
</rss>

