<?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: DATEADD in calculated table cannot use column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATEADD-in-calculated-table-cannot-use-column/m-p/726162#M1550</link>
    <description>&lt;P&gt;Functions that work with dates need input that is a DATE (and even though sometimes type coercion kicks in, you should NEVER rely on that), so please make sure you have the right input into your functions. What's more, some of them need input in the form of a column with specific data types, some work on pure dates (disconnected from any tables). For the correct syntax and data types, please refer to &lt;A href="https://dax.guide/" target="_blank" rel="noopener"&gt;DAX Guide&lt;/A&gt;. You'll find everything you need in there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By the way...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;var __today = TODAY()
var __todayBackInTime = EDATE( __today, -12 ) 
return
	{ __todayBackInTime }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jun 2019 12:12:34 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-06-27T12:12:34Z</dc:date>
    <item>
      <title>DATEADD in calculated table cannot use column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATEADD-in-calculated-table-cannot-use-column/m-p/723980#M1474</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have following code that creates calculated table with dates for 12 months rolling period.&lt;/P&gt;&lt;P&gt;For some reason I cannot use DATEADD function using column (it gets underlined as error and table does not materialize). I have this stupid workaround to use just&amp;nbsp;[YearMonthTrunc_B]&amp;gt;([YearMonthTrunc_A]&lt;FONT color="#FF0000"&gt;-365&lt;/FONT&gt;) but this is causing some issues for leap-years.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there something better to use than DATEADD?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any response,&lt;/P&gt;&lt;P&gt;Zuzana&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Table = 
var monthrange = SELECTCOLUMNS( ADDCOLUMNS(SUMMARIZECOLUMNS('_Date - renewal'[YearMonthTrunc])
                                ,"YearMonth",FORMAT('_Date - renewal'[YearMonthTrunc],"YYYY/MM"))
                 ,"YearMonth_A",[YearMonth]
                 ,"YearMonthTrunc_A",[YearMonthTrunc])
var rollingperiod = SELECTCOLUMNS( ADDCOLUMNS(SUMMARIZECOLUMNS('_Date - renewal'[YearMonthTrunc])
                                   ,"YearMonth",FORMAT('_Date - renewal'[YearMonthTrunc],"YYYY/MM"))
                 ,"YearMonth_B",[YearMonth]
                 ,"YearMonthTrunc_B",[YearMonthTrunc])
                                  
return
FILTER(CALCULATETABLE(CROSSJOIN(monthrange,rollingperiod))
       ,AND([YearMonthTrunc_B]&amp;lt;=[YearMonthTrunc_A]
      &lt;FONT color="#FF0000"&gt; ,[YearMonthTrunc_B]&amp;gt;DATEADD([YearMonthTrunc_A],-12,MONTH))&lt;/FONT&gt;
       )
            &lt;/PRE&gt;&lt;P&gt;Table '&lt;SPAN&gt;_Date - renewal' is also calculated:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;_Date - renewal = 
ADDCOLUMNS (
CALENDAR (min(data[start_date]),TODAY()),
"YearMonthTrunc", date(year([date]),month([date]),1),&lt;/PRE&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 25 Jun 2019 17:17:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATEADD-in-calculated-table-cannot-use-column/m-p/723980#M1474</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-25T17:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: DATEADD in calculated table cannot use column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATEADD-in-calculated-table-cannot-use-column/m-p/726162#M1550</link>
      <description>&lt;P&gt;Functions that work with dates need input that is a DATE (and even though sometimes type coercion kicks in, you should NEVER rely on that), so please make sure you have the right input into your functions. What's more, some of them need input in the form of a column with specific data types, some work on pure dates (disconnected from any tables). For the correct syntax and data types, please refer to &lt;A href="https://dax.guide/" target="_blank" rel="noopener"&gt;DAX Guide&lt;/A&gt;. You'll find everything you need in there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By the way...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;var __today = TODAY()
var __todayBackInTime = EDATE( __today, -12 ) 
return
	{ __todayBackInTime }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 12:12:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATEADD-in-calculated-table-cannot-use-column/m-p/726162#M1550</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-27T12:12:34Z</dc:date>
    </item>
  </channel>
</rss>

