<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Converting the datasubset</title><link>https://community.appian.com/discussions/f/general/17579/converting-the-datasubset</link><description>Hi, I have a datasubset: 
 { {impact: 0.0, country_nm: &amp;quot;AA&amp;quot;, year: &amp;quot;2019&amp;quot;}, 
 {impact: 0.0, country_nm: &amp;quot;AA&amp;quot;, year: &amp;quot;2020&amp;quot;}, 
 {impact: 0.0, country_nm: &amp;quot;AA&amp;quot;, year: &amp;quot;2021&amp;quot;}, 
 {impact: 0.0, country_nm: &amp;quot;AA&amp;quot;, year: &amp;quot;2022&amp;quot;}, 
 {impact: 0.0, country_nm:</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Converting the datasubset</title><link>https://community.appian.com/thread/69282?ContentTypeID=1</link><pubDate>Mon, 09 Sep 2019 07:06:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7f8f5be2-8988-4892-838a-ae4e8cb54e55</guid><dc:creator>Harshit Bumb (Appyzie)</dc:creator><description>&lt;p&gt;Hey&amp;nbsp;&lt;a href="/members/ramanh"&gt;ramanh&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;Before the solution, I would like to tell you that the dataset you are trying to achieve requires a little modification. You are trying to create a syntactically incorrect dictionary because you mixed the keyword and non-keyword arguments/values. Ex:&amp;nbsp;{country_nm: &amp;quot;BB&amp;quot;,{year: &amp;quot;2019&amp;quot;, impact:0}}. The first index of the&amp;nbsp;&lt;span&gt;dictionary has &amp;quot;country_nm&amp;quot; as key but the second index does not have any key. The required dataset can be achieved by adding a key to the second index. You can find a code below to achieve the same.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!dataSet: {
    {impact: 0.0, country_nm: &amp;quot;AA&amp;quot;, year: &amp;quot;2019&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;AA&amp;quot;, year: &amp;quot;2020&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;AA&amp;quot;, year: &amp;quot;2021&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;AA&amp;quot;, year: &amp;quot;2022&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;AA&amp;quot;, year: &amp;quot;2023&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;BB&amp;quot;, year: &amp;quot;2019&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;BB&amp;quot;, year: &amp;quot;2020&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;BB&amp;quot;, year: &amp;quot;2021&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;BB&amp;quot;, year: &amp;quot;2022&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;BB&amp;quot;, year: &amp;quot;2023&amp;quot;}
  },

  a!forEach(
    items: union(local!dataSet.country_nm, local!dataSet.country_nm),
    expression: {
      country_nm: fv!item,
      data:{
        a!forEach(
          items: index(local!dataSet,wherecontains(fv!item,touniformstring(local!dataSet.country_nm)),{}),
          expression: {
            year: fv!item.year,
            impact: fv!item.impact
          }
        )
      }
    }
  )
)&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Converting the datasubset</title><link>https://community.appian.com/thread/69271?ContentTypeID=1</link><pubDate>Fri, 06 Sep 2019 16:25:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bfb1b2d4-11e4-4e4a-b3c5-9546ad70491a</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;FWIW, &lt;em&gt;a!forEach&lt;/em&gt; is unexpectedly powerful, and can be nested pretty easily.&amp;nbsp; This is what I was able to whip up quickly:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  
  local!originalData: {
    {impact: 0.0, country_nm: &amp;quot;AA&amp;quot;, year: &amp;quot;2019&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;AA&amp;quot;, year: &amp;quot;2020&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;AA&amp;quot;, year: &amp;quot;2021&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;AA&amp;quot;, year: &amp;quot;2022&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;AA&amp;quot;, year: &amp;quot;2023&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;BB&amp;quot;, year: &amp;quot;2019&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;BB&amp;quot;, year: &amp;quot;2020&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;BB&amp;quot;, year: &amp;quot;2021&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;BB&amp;quot;, year: &amp;quot;2022&amp;quot;},
    {impact: 0.0, country_nm: &amp;quot;BB&amp;quot;, year: &amp;quot;2023&amp;quot;}
  },
  
  local!uniqueCountries: union(local!originalData.country_nm, local!originalData.country_nm),
  
  a!forEach(
    local!uniqueCountries,
    a!localVariables(
      local!currentCountry: fv!item,
      {
        country_nm: fv!item,
        country_data: a!forEach(
          local!originalData,
          if(
            fv!item.country_nm = local!currentCountry,
            {
              year: fv!item.year,
              impact: fv!item.impact
            },
            {}
          )
        )
      }
    )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;it seems to do what you want, though in the transformed data set it&amp;#39;s necessary to label the &amp;quot;year data&amp;quot; arrays i believe.&lt;/p&gt;
&lt;p&gt;&lt;img height="233" src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/pastedimage1567787132027v1.png" width="388" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>