<?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: Calculate averages and moving averages in SAS Visual Analytics</title>
    <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculate-averages-and-moving-averages/m-p/146513#M354</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming you have a date type category 'date' and you wish to calculate the current YTD sales and average YTD sales of the prior four years of the measure 'sales', you can create an aggregated measure named 'YTD sales (current)' containing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CumulativePeriod(_Sum_, 'sales'n, 'date'n, _Inferred_, _ByYear_, 0, _Full_, {Date})&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In addition, you can create an aggregated measure named 'YTD sales (average of prior four years)' containing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;( CumulativePeriod(_Sum_, 'sales'n, 'date'n, _Inferred_, _ByYear_, -1, _Full_, {Date})&lt;/P&gt;&lt;P&gt;+ CumulativePeriod(_Sum_, 'sales'n, 'date'n, _Inferred_, _ByYear_, -2, _Full_, {Date})&lt;/P&gt;&lt;P&gt;+ CumulativePeriod(_Sum_, 'sales'n, 'date'n, _Inferred_, _ByYear_, -3, _Full_, {Date})&lt;/P&gt;&lt;P&gt;+ CumulativePeriod(_Sum_, 'sales'n, 'date'n, _Inferred_, _ByYear_, -4, _Full_, {Date}) ) / 4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will work, but I'm affraid this solution is not quite optimized: ideally you'd apply a RelativePeriod periodic aggregation to 'YTD sales (current)' in order to obtain the values for the prior four years in computing the average, but since it's already aggregated this will not work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Feb 2015 08:36:04 GMT</pubDate>
    <dc:creator>WouterHordijk</dc:creator>
    <dc:date>2015-02-17T08:36:04Z</dc:date>
    <item>
      <title>Calculate averages and moving averages</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculate-averages-and-moving-averages/m-p/146512#M353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way calculate averages and moving averages in VA?&amp;nbsp; I'm trying to calculate how the current year-to-date totals (sales, profit, etc.) of a product or products compares to the average of the prior four years at this same point in the year?&amp;nbsp; For example, the current YTD sales through March is $1.5 million and the prior four year average through March is $1.2 million.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is appreciated.&amp;nbsp; Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2015 18:11:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculate-averages-and-moving-averages/m-p/146512#M353</guid>
      <dc:creator>paul1034</dc:creator>
      <dc:date>2015-01-30T18:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate averages and moving averages</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculate-averages-and-moving-averages/m-p/146513#M354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming you have a date type category 'date' and you wish to calculate the current YTD sales and average YTD sales of the prior four years of the measure 'sales', you can create an aggregated measure named 'YTD sales (current)' containing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CumulativePeriod(_Sum_, 'sales'n, 'date'n, _Inferred_, _ByYear_, 0, _Full_, {Date})&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In addition, you can create an aggregated measure named 'YTD sales (average of prior four years)' containing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;( CumulativePeriod(_Sum_, 'sales'n, 'date'n, _Inferred_, _ByYear_, -1, _Full_, {Date})&lt;/P&gt;&lt;P&gt;+ CumulativePeriod(_Sum_, 'sales'n, 'date'n, _Inferred_, _ByYear_, -2, _Full_, {Date})&lt;/P&gt;&lt;P&gt;+ CumulativePeriod(_Sum_, 'sales'n, 'date'n, _Inferred_, _ByYear_, -3, _Full_, {Date})&lt;/P&gt;&lt;P&gt;+ CumulativePeriod(_Sum_, 'sales'n, 'date'n, _Inferred_, _ByYear_, -4, _Full_, {Date}) ) / 4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will work, but I'm affraid this solution is not quite optimized: ideally you'd apply a RelativePeriod periodic aggregation to 'YTD sales (current)' in order to obtain the values for the prior four years in computing the average, but since it's already aggregated this will not work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2015 08:36:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculate-averages-and-moving-averages/m-p/146513#M354</guid>
      <dc:creator>WouterHordijk</dc:creator>
      <dc:date>2015-02-17T08:36:04Z</dc:date>
    </item>
  </channel>
</rss>

