<?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 SAS Visual Analytics Report Creating Last Year KPI's in SAS Visual Analytics</title>
    <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-Visual-Analytics-Report-Creating-Last-Year-KPI-s/m-p/950116#M18468</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a report that contains sales dataset. I have sales over years. I want to select a year from page prompt and see my list table showing selected year's and its previous year's total sales data in 2 different columns. I tried to create a parameter but failed to combine with a KPI. How is it possible?&lt;/P&gt;</description>
    <pubDate>Thu, 07 Nov 2024 14:27:55 GMT</pubDate>
    <dc:creator>fda2</dc:creator>
    <dc:date>2024-11-07T14:27:55Z</dc:date>
    <item>
      <title>SAS Visual Analytics Report Creating Last Year KPI's</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-Visual-Analytics-Report-Creating-Last-Year-KPI-s/m-p/950116#M18468</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a report that contains sales dataset. I have sales over years. I want to select a year from page prompt and see my list table showing selected year's and its previous year's total sales data in 2 different columns. I tried to create a parameter but failed to combine with a KPI. How is it possible?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 14:27:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-Visual-Analytics-Report-Creating-Last-Year-KPI-s/m-p/950116#M18468</guid>
      <dc:creator>fda2</dc:creator>
      <dc:date>2024-11-07T14:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Visual Analytics Report Creating Last Year KPI's</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-Visual-Analytics-Report-Creating-Last-Year-KPI-s/m-p/950367#M18472</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/467553"&gt;@fda2&lt;/a&gt;! Here is one way to go about it. Let's say your data looks like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;Year&lt;/TD&gt;
&lt;TD width="50%"&gt;Sales&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;2021&lt;/TD&gt;
&lt;TD width="50%"&gt;$1000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;2022&lt;/TD&gt;
&lt;TD width="50%"&gt;$2000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;2023&lt;/TD&gt;
&lt;TD width="50%"&gt;$2500&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;2024&lt;/TD&gt;
&lt;TD width="50%"&gt;$4000&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use a parameter, calculated item, and a list table to achieve this. Here's how you do it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create a new numeric parameter called "Year Select"&lt;/LI&gt;
&lt;LI&gt;Create a new calculated column called "Prior Year Sales":&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if 'Year'n = 'Year Select'p-1 return 'Sales'n
    else .&lt;/CODE&gt;&lt;/PRE&gt;
This will set every value to missing if it is not the prior year that is selected from the drop-down list control. Otherwise, it will populate the value. This is what we want, becuase SAS will return only the non-missing value.&lt;/LI&gt;
&lt;LI&gt;Create another calculated item and call it "Selected Year Sales":&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if 'Year'n = 'Year Select'p return 'Sales'n
    else .&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Create a new drop-down list control on canvas and add "Year" as the category and "Year Select" as the parameter. Set the drop-down list as required, but do not add any actions to the drop-down list.&lt;/LI&gt;
&lt;LI&gt;Add a new list table to canvas and add "Selected Year Sales" and "Prior Year Sales" as the columns.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;You're done! When you select a year, the calculated item updates and your list table displays the prior year's value.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Stu_SAS_0-1731344935834.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/102071iE4E5950DD469583F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Stu_SAS_0-1731344935834.png" alt="Stu_SAS_0-1731344935834.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;How does this work?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Let's go behind the scenes. The parameter is taking on a value based on what is selected in the drop-down list control. When you select 2022, your calculated columns are updating like this in the background:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;Year&lt;/TD&gt;
&lt;TD width="23.11111111111111%"&gt;'Year Select'p&lt;/TD&gt;
&lt;TD width="14.38888888888889%"&gt;'Selected Year Sales'n&lt;/TD&gt;
&lt;TD width="12.5%"&gt;'Prior Year Sales'n&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;
&lt;P&gt;2021&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="23.11111111111111%"&gt;2022&lt;/TD&gt;
&lt;TD width="14.38888888888889%"&gt;.&lt;/TD&gt;
&lt;TD width="12.5%"&gt;$1000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;2022&lt;/TD&gt;
&lt;TD width="23.11111111111111%"&gt;2022&lt;/TD&gt;
&lt;TD width="14.38888888888889%"&gt;$2000&lt;/TD&gt;
&lt;TD width="12.5%"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;2023&lt;/TD&gt;
&lt;TD width="23.11111111111111%"&gt;2022&lt;/TD&gt;
&lt;TD width="14.38888888888889%"&gt;.&lt;/TD&gt;
&lt;TD width="12.5%"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;2024&lt;/TD&gt;
&lt;TD width="23.11111111111111%"&gt;2022&lt;/TD&gt;
&lt;TD width="14.38888888888889%"&gt;.&lt;/TD&gt;
&lt;TD width="12.5%"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS will try to sum all of these values. Missing values are excluded from the sum, leaving only $2000 and $1000 left. Therefore, the returned values in the list table are $2000 for 2022 and $1000 for 2021.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;An alternative way&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;One simpler way would be to use a crosstab and add the following filter to it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;In('Year'n, 'Year Select'p, 'Year Select'p-1)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will filter the crosstab down to the selected year and the prior year:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Stu_SAS_0-1731345737048.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/102072i73A74AFC8E72EFF6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Stu_SAS_0-1731345737048.png" alt="Stu_SAS_0-1731345737048.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also use Key Values with a lattice category this way, too!&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Stu_SAS_0-1731346018720.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/102073iE7FBDF9C12FAF9AF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Stu_SAS_0-1731346018720.png" alt="Stu_SAS_0-1731346018720.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2024 18:36:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-Visual-Analytics-Report-Creating-Last-Year-KPI-s/m-p/950367#M18472</guid>
      <dc:creator>Stu_SAS</dc:creator>
      <dc:date>2024-11-11T18:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Visual Analytics Report Creating Last Year KPI's</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-Visual-Analytics-Report-Creating-Last-Year-KPI-s/m-p/950424#M18473</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/61362"&gt;@Stu_SAS&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thanks for the great solution and comprehensive expression! Your solution worked. I have a question about key-value pairs. You named KPI's as "&lt;SPAN&gt;Selected Year Sales" and "Prior Year Sales". How did you show only the name of "Sales" in your key-value pair cards? And how did you show the year value differently in key-value cards?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 07:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-Visual-Analytics-Report-Creating-Last-Year-KPI-s/m-p/950424#M18473</guid>
      <dc:creator>fda2</dc:creator>
      <dc:date>2024-11-12T07:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Visual Analytics Report Creating Last Year KPI's</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-Visual-Analytics-Report-Creating-Last-Year-KPI-s/m-p/950438#M18474</link>
      <description>&lt;P&gt;The reason for this is because I used the Sales variable within the key value rather than the calculated items, "Current Year Sales" and "Prior Year Sales." Since the key value is using a paramaterized filter with a lattice group of "Year", we do not need to use the calculated items to identify the selected year and the prior year.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 14:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-Visual-Analytics-Report-Creating-Last-Year-KPI-s/m-p/950438#M18474</guid>
      <dc:creator>Stu_SAS</dc:creator>
      <dc:date>2024-11-12T14:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Visual Analytics Report Creating Last Year KPI's</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-Visual-Analytics-Report-Creating-Last-Year-KPI-s/m-p/950445#M18477</link>
      <description>Alright got it, thanks!</description>
      <pubDate>Tue, 12 Nov 2024 15:01:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-Visual-Analytics-Report-Creating-Last-Year-KPI-s/m-p/950445#M18477</guid>
      <dc:creator>fda2</dc:creator>
      <dc:date>2024-11-12T15:01:31Z</dc:date>
    </item>
  </channel>
</rss>

