<?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 Re: Conditional Filter in a dataset in SAS Viya</title>
    <link>https://communities.sas.com/t5/SAS-Viya/Conditional-Filter-in-a-dataset/m-p/702127#M751</link>
    <description>&lt;P&gt;One way to handle this is to derive a numeric month counter in your data. For example current month could be 0, back one month -1, back two months -2 and so on. Your planned data would be forward one month +1 and so on. Then your filter based on the month counter would be from -11 to +3 to get the last 12 months actual data plus the next 3 months planned data.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Nov 2020 22:42:17 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2020-11-27T22:42:17Z</dc:date>
    <item>
      <title>Conditional Filter in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Conditional-Filter-in-a-dataset/m-p/702099#M750</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am in a middle of creating a Sales Dashboard where I have to create a Conditional Filter for my Bar &amp;amp; Line chart. My dataset consists 24 months data of actual against planned numbers. I want to see only current year plan and actual data with plus next 3 months planned number. Any suggestions on how to apply filter in such a way that I don't need to adjust it manually every month. Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 19:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Conditional-Filter-in-a-dataset/m-p/702099#M750</guid>
      <dc:creator>Devilsmile_20</dc:creator>
      <dc:date>2020-11-27T19:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Filter in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Conditional-Filter-in-a-dataset/m-p/702127#M751</link>
      <description>&lt;P&gt;One way to handle this is to derive a numeric month counter in your data. For example current month could be 0, back one month -1, back two months -2 and so on. Your planned data would be forward one month +1 and so on. Then your filter based on the month counter would be from -11 to +3 to get the last 12 months actual data plus the next 3 months planned data.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 22:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Conditional-Filter-in-a-dataset/m-p/702127#M751</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-11-27T22:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Filter in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Conditional-Filter-in-a-dataset/m-p/702336#M752</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the solution but can you elaborate on how to derive the counter in the data.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Nov 2020 19:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Conditional-Filter-in-a-dataset/m-p/702336#M752</guid>
      <dc:creator>Devilsmile_20</dc:creator>
      <dc:date>2020-11-29T19:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Filter in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Conditional-Filter-in-a-dataset/m-p/702582#M753</link>
      <description>&lt;P&gt;I assume you want to do this in a Visual Analytics Report, is that right? If so, I would move to the Visual Analytics board.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please have a look at this post&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Calculating-First-and-Last-Days-of-the-Current-and-Future-Months/ta-p/307993" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Calculating-First-and-Last-Days-of-the-Current-and-Future-Months/ta-p/307993&lt;/A&gt;&amp;nbsp;by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1484"&gt;@Renato_sas&lt;/a&gt;. He explains on how to calculate the dates your are after.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To save you some time, here is the formula to calculate n months from "now"&lt;/P&gt;
&lt;PRE&gt;DateFromMDY(( ( ( Month('now - date'n) + ( 'n_months'p - 1 ) + 1200 ) Mod 12 ) + 1 ), 1, ( ( Year('now - date'n) + Trunc(( (Month('now - date'n) + ( 'n_months'p - 1 ) + 1200 ) / 12 )) ) -100 ))&lt;/PRE&gt;
&lt;P&gt;Please note, this expression is using "now - date" (datepart of now) and a parameter named n_months. I used the parameter for testing purposes, -n to go n months back, +n to go n months forward.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some other examples, First of next month&lt;/P&gt;
&lt;PRE&gt;DateFromMDY(( ( Month('now - date'n) Mod 12 ) + 1 ), 1, ( Year('now - date'n) + Trunc(( Month('now - date'n) / 12 )) ))&lt;/PRE&gt;
&lt;P&gt;Last day of current month, makes use of previous result&lt;/P&gt;
&lt;PRE&gt;TreatAs(_Date_, ( TreatAs(_Number_, 'first_of_next_month'n) - 1 ))&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Nov 2020 17:37:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Conditional-Filter-in-a-dataset/m-p/702582#M753</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2020-11-30T17:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Filter in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Conditional-Filter-in-a-dataset/m-p/703210#M755</link>
      <description>&lt;P&gt;It's actually very easy. Assuming you already have a reporting date defined as a SAS date in your data this is how you do it - Reporting_Month is the counter:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  Reporting_Month = intck('MONTH', today(), Reporting_Date);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Dec 2020 21:49:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Conditional-Filter-in-a-dataset/m-p/703210#M755</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-12-02T21:49:20Z</dc:date>
    </item>
  </channel>
</rss>

