<?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: Set value from existing column/row when adding new column to fact table. in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Set-value-from-existing-column-row-when-adding-new-column-to/m-p/81484#M116</link>
    <description>&lt;P&gt;Is it what you were looking for?&lt;/P&gt;&lt;PRE&gt;CALCULATE( MAX('Table'[Attribute])
       ,'Table'[Year] = &lt;STRONG&gt;EARLIER&lt;/STRONG&gt;('Table'[Year])- 1
       ,'Table[Widget_ID] = &lt;STRONG&gt;EARLIER&lt;/STRONG&gt;('Table'[Widget_ID])
)&lt;/PRE&gt;&lt;P&gt;Note that, due to the way CALCULATE works, you may get unexpected results if your table has more columns than in your description.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You may prefer something like the following instead:&lt;/P&gt;&lt;PRE&gt;MAXX( FILTER('Table'
               ,'Table'[Year] = EARLIER('Table'[Year])- 1
               &amp;amp;&amp;amp; 'Table[Widget_ID] = EARLIER('Table'[Widget_ID]
           )
          , [Attribute]
)&lt;/PRE&gt;</description>
    <pubDate>Mon, 24 Oct 2016 09:41:45 GMT</pubDate>
    <dc:creator>LaurentCouartou</dc:creator>
    <dc:date>2016-10-24T09:41:45Z</dc:date>
    <item>
      <title>Set value from existing column/row when adding new column to fact table.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Set-value-from-existing-column-row-when-adding-new-column-to/m-p/80526#M114</link>
      <description>&lt;P&gt;I have a fact table which lists widgets, years, and an attribute of the widget in that year. For example:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333"&gt;&lt;STRONG&gt;Widget_ID&amp;nbsp;&amp;nbsp;&amp;nbsp; Year&amp;nbsp;&amp;nbsp;&amp;nbsp; Attribute&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;1001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2005&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;BR /&gt;1001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2006&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&lt;BR /&gt;1001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2007&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12&lt;BR /&gt;1001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2008&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'd like to do is create another column that has the value of the widget's previous year attribute, which should look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Widget_ID&amp;nbsp;&amp;nbsp;&amp;nbsp; Year&amp;nbsp;&amp;nbsp;&amp;nbsp; Attribute&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PY Attribute&lt;/STRONG&gt;&lt;BR /&gt;1001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2005&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; N/A&lt;BR /&gt;1001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2006&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;BR /&gt;1001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2007&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&lt;BR /&gt;1001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2008&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been playing around with CALCULATE and FILTER commands, but I feel very clumsy with DAX at this point. Here is the gist of what I've been trying:&lt;/P&gt;&lt;P&gt;PY Attribute = CALCULATE(MAX('Table'[Attribue]),'Table'[Year] = ('Table'[Year] - 1),'Table[Widget_ID] ='Table'[Widget_ID])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice or tips would be appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 14:44:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Set-value-from-existing-column-row-when-adding-new-column-to/m-p/80526#M114</guid>
      <dc:creator>dsandberg</dc:creator>
      <dc:date>2016-10-20T14:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: Set value from existing column/row when adding new column to fact table.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Set-value-from-existing-column-row-when-adding-new-column-to/m-p/81484#M116</link>
      <description>&lt;P&gt;Is it what you were looking for?&lt;/P&gt;&lt;PRE&gt;CALCULATE( MAX('Table'[Attribute])
       ,'Table'[Year] = &lt;STRONG&gt;EARLIER&lt;/STRONG&gt;('Table'[Year])- 1
       ,'Table[Widget_ID] = &lt;STRONG&gt;EARLIER&lt;/STRONG&gt;('Table'[Widget_ID])
)&lt;/PRE&gt;&lt;P&gt;Note that, due to the way CALCULATE works, you may get unexpected results if your table has more columns than in your description.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You may prefer something like the following instead:&lt;/P&gt;&lt;PRE&gt;MAXX( FILTER('Table'
               ,'Table'[Year] = EARLIER('Table'[Year])- 1
               &amp;amp;&amp;amp; 'Table[Widget_ID] = EARLIER('Table'[Widget_ID]
           )
          , [Attribute]
)&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Oct 2016 09:41:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Set-value-from-existing-column-row-when-adding-new-column-to/m-p/81484#M116</guid>
      <dc:creator>LaurentCouartou</dc:creator>
      <dc:date>2016-10-24T09:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: Set value from existing column/row when adding new column to fact table.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Set-value-from-existing-column-row-when-adding-new-column-to/m-p/81711#M117</link>
      <description>&lt;P&gt;Yes, this worked; I used the MAXX option because my table did have more columns. The column formula turned out to be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;=MAXX(FILTER('Table',('Table'[Widget_ID] = EARLIEST('Table'[Widget_ID]) &amp;amp;&amp;amp; 'Table'[Year] = EARLIER('Table'[Year])-1)),[Attribute])&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 19:16:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Set-value-from-existing-column-row-when-adding-new-column-to/m-p/81711#M117</guid>
      <dc:creator>dsandberg</dc:creator>
      <dc:date>2016-10-24T19:16:52Z</dc:date>
    </item>
  </channel>
</rss>

