<?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 % DIFFERENCE FOR AN AGGREGATED MEASURE in SAS Visual Analytics</title>
    <link>https://communities.sas.com/t5/SAS-Visual-Analytics/DIFFERENCE-FOR-AN-AGGREGATED-MEASURE/m-p/452536#M9866</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am looking for someone helping me with an issue. I need to calculate the percentage difference from the previous parallel period (same month in the previous year) and from the previous period (previous month) for an aggregate measure that is calculated as following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Distinct [_ByGroup_] ('ID'n)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID is the identification code for unique client. And I also need this all to be parametrized. To sum up, right now in the report, I can choose a date (that is collected in the parameter Selected_date) and for that date I can see:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The count from the beginning of the current month up to Selected_date&lt;/LI&gt;&lt;LI&gt;The count from the beginning of the same month in the previous year (up to the day of the month defined in Selected_date)&lt;/LI&gt;&lt;LI&gt;The count from the beginning of the previous month and up to the day of the month defined in Selected_date&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;What I need to find and show is the percentage difference for both cases. Let’s focus on the difference from the previous month. Concerning to the % difference from the previous month, right now we have an aggregate measure calculated as follow:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;( RelativePeriod(_DistinctCount_, 'ID'n, _ApplyAllFilters_, 'Order_date'n, _ByMonth_, 0, _Full_, {Date}) / RelativePeriod(_DistinctCount_, 'ID'n, _ApplyAllFilters_, 'Order_date'n, _ByMonth_, -1, _Full_, {Date}) ) - 1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Order_date is the date we need to take into consideration when counting, the date in which the order has taken place. And we also are applying the following filter directly in the report object:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;IF ( 'Selected Measure'p = 'MTD' )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;RETURN (&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&amp;nbsp; IF ( Month('Selected_date'p) = 1 )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&amp;nbsp; RETURN ( ( ( 'Order_date'n &amp;gt;= DateFromMDY(12, 1, ( Year('Selected_date'p) - 1 )) ) AND ( 'Order_date'n &amp;lt;= DateFromMDY(12, DayOfMonth('Selected_date'p), ( Year('Selected_date'p) - 1 )) ) ) OR ( ( 'Order_date'n &amp;gt;= DateFromMDY(1, 1, Year('Selected_date'p)) ) AND ( 'Order_date'n &amp;lt;= DateFromMDY(1, DayOfMonth('Selected_date'p), Year('Selected_date'p)) ) ) )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&amp;nbsp; ELSE ( ( ( 'Order_date'n &amp;gt;= DateFromMDY(( Month('Selected_date'p) - 1 ), 1, Year('Selected_date'p)) ) AND ( 'Order_date'n &amp;lt;= DateFromMDY(( Month('Selected_date'p) - 1 ), DayOfMonth('Selected_date'p), Year('Selected_date'p)) ) ) OR ( ( 'Order_date'n &amp;gt;= DateFromMDY(Month('Selected_date'p), 1, Year('Selected_date'p)) ) AND ( 'Order_date'n &amp;lt;= DateFromMDY(Month('Selected_date'p), DayOfMonth('Selected_date'p), Year('Selected_date'p)) ) ) ) )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ELSE ( 'Order_date'n &amp;gt; DateFromMDY(1, 1, 2999) )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this measure is working only for the current month and it returns 100% if we select a date in March (month previous to the current one) and “missing” if we select a date in a month previous to March. Is there anyone who can help me in fixing it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you a lot and I am at disposal for any clarification!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Giulia&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Apr 2018 15:53:43 GMT</pubDate>
    <dc:creator>GiuliaM</dc:creator>
    <dc:date>2018-04-09T15:53:43Z</dc:date>
    <item>
      <title>% DIFFERENCE FOR AN AGGREGATED MEASURE</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/DIFFERENCE-FOR-AN-AGGREGATED-MEASURE/m-p/452536#M9866</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am looking for someone helping me with an issue. I need to calculate the percentage difference from the previous parallel period (same month in the previous year) and from the previous period (previous month) for an aggregate measure that is calculated as following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Distinct [_ByGroup_] ('ID'n)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID is the identification code for unique client. And I also need this all to be parametrized. To sum up, right now in the report, I can choose a date (that is collected in the parameter Selected_date) and for that date I can see:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The count from the beginning of the current month up to Selected_date&lt;/LI&gt;&lt;LI&gt;The count from the beginning of the same month in the previous year (up to the day of the month defined in Selected_date)&lt;/LI&gt;&lt;LI&gt;The count from the beginning of the previous month and up to the day of the month defined in Selected_date&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;What I need to find and show is the percentage difference for both cases. Let’s focus on the difference from the previous month. Concerning to the % difference from the previous month, right now we have an aggregate measure calculated as follow:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;( RelativePeriod(_DistinctCount_, 'ID'n, _ApplyAllFilters_, 'Order_date'n, _ByMonth_, 0, _Full_, {Date}) / RelativePeriod(_DistinctCount_, 'ID'n, _ApplyAllFilters_, 'Order_date'n, _ByMonth_, -1, _Full_, {Date}) ) - 1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Order_date is the date we need to take into consideration when counting, the date in which the order has taken place. And we also are applying the following filter directly in the report object:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;IF ( 'Selected Measure'p = 'MTD' )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;RETURN (&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&amp;nbsp; IF ( Month('Selected_date'p) = 1 )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&amp;nbsp; RETURN ( ( ( 'Order_date'n &amp;gt;= DateFromMDY(12, 1, ( Year('Selected_date'p) - 1 )) ) AND ( 'Order_date'n &amp;lt;= DateFromMDY(12, DayOfMonth('Selected_date'p), ( Year('Selected_date'p) - 1 )) ) ) OR ( ( 'Order_date'n &amp;gt;= DateFromMDY(1, 1, Year('Selected_date'p)) ) AND ( 'Order_date'n &amp;lt;= DateFromMDY(1, DayOfMonth('Selected_date'p), Year('Selected_date'p)) ) ) )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&amp;nbsp; ELSE ( ( ( 'Order_date'n &amp;gt;= DateFromMDY(( Month('Selected_date'p) - 1 ), 1, Year('Selected_date'p)) ) AND ( 'Order_date'n &amp;lt;= DateFromMDY(( Month('Selected_date'p) - 1 ), DayOfMonth('Selected_date'p), Year('Selected_date'p)) ) ) OR ( ( 'Order_date'n &amp;gt;= DateFromMDY(Month('Selected_date'p), 1, Year('Selected_date'p)) ) AND ( 'Order_date'n &amp;lt;= DateFromMDY(Month('Selected_date'p), DayOfMonth('Selected_date'p), Year('Selected_date'p)) ) ) ) )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ELSE ( 'Order_date'n &amp;gt; DateFromMDY(1, 1, 2999) )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this measure is working only for the current month and it returns 100% if we select a date in March (month previous to the current one) and “missing” if we select a date in a month previous to March. Is there anyone who can help me in fixing it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you a lot and I am at disposal for any clarification!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Giulia&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2018 15:53:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/DIFFERENCE-FOR-AN-AGGREGATED-MEASURE/m-p/452536#M9866</guid>
      <dc:creator>GiuliaM</dc:creator>
      <dc:date>2018-04-09T15:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: % DIFFERENCE FOR AN AGGREGATED MEASURE</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/DIFFERENCE-FOR-AN-AGGREGATED-MEASURE/m-p/452612#M9868</link>
      <description>&lt;P&gt;Hi Giulia,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It sounds like you want to perform a nested aggregation (applying RelativePeriod() to an aggregated measure using Distinct()).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Visual Analytics does not support nested aggregations, so I think you would need to calculate your distinct count as part of your data query. Would this be possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;Sam&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2018 19:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/DIFFERENCE-FOR-AN-AGGREGATED-MEASURE/m-p/452612#M9868</guid>
      <dc:creator>Sam_SAS</dc:creator>
      <dc:date>2018-04-09T19:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: % DIFFERENCE FOR AN AGGREGATED MEASURE</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/DIFFERENCE-FOR-AN-AGGREGATED-MEASURE/m-p/452721#M9869</link>
      <description>&lt;P&gt;Hi Sam,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, to work on the data query is not possible right now. Isn't there any shortcut or way to do it anyway?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Giulia&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 07:15:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/DIFFERENCE-FOR-AN-AGGREGATED-MEASURE/m-p/452721#M9869</guid>
      <dc:creator>GiuliaM</dc:creator>
      <dc:date>2018-04-10T07:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: % DIFFERENCE FOR AN AGGREGATED MEASURE</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/DIFFERENCE-FOR-AN-AGGREGATED-MEASURE/m-p/452817#M9872</link>
      <description>&lt;P&gt;The standard workaround is to modify the data query, but there may be other ways.&lt;BR /&gt;&lt;BR /&gt;The post at the bottom of this thread might be helpful?&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Visual-Analytics/Aggregation-of-an-aggregation/m-p/312213/highlight/true#M5828" target="_blank"&gt;https://communities.sas.com/t5/SAS-Visual-Analytics/Aggregation-of-an-aggregation/m-p/312213/highlight/true#M5828&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(Actually no, I don't think it will help if you need Distinct Count.)&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 13:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/DIFFERENCE-FOR-AN-AGGREGATED-MEASURE/m-p/452817#M9872</guid>
      <dc:creator>Sam_SAS</dc:creator>
      <dc:date>2018-04-10T13:37:59Z</dc:date>
    </item>
  </channel>
</rss>

