<?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: Get previous YYYY-MM value based on existing YYYY-MM value in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2015844#M44845</link>
    <description>&lt;P&gt;Interesting. Gave this a try but am getting following error when doing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;EM&gt;PY = MAX('Calendar'[Year]) - 1 &amp;lt;= this calculates previous year value, i formatted General with no decimals (couldn't choose Text)&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;EM&gt;Measure = CALCULATE([Actual], '&lt;SPAN&gt;Calendar&lt;/SPAN&gt;'[Year] = [PY]) &amp;lt;= this gives error:&amp;nbsp;&lt;/EM&gt;&lt;EM&gt;"A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed."&lt;/EM&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did I do this as you explained? It was clear exactly what you meant by&amp;nbsp;&lt;EM&gt;"Calendar Year Number in Date Dimension Table"&lt;/EM&gt;?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Fri, 13 Aug 2021 17:53:43 GMT</pubDate>
    <dc:creator>009co</dc:creator>
    <dc:date>2021-08-13T17:53:43Z</dc:date>
    <item>
      <title>Get previous YYYY-MM value based on existing YYYY-MM value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2013821#M44778</link>
      <description>&lt;P&gt;My dataset has rows by year and month. It&amp;nbsp; has a related calendar table. In my reporting I am using&amp;nbsp;the calendar table YYYY-MM value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The calendar table also has a proper date column for the last day of the month.&amp;nbsp;I can create a previous year date using:&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;date PY = DATEADD('Calendar'[Date],-1,year) &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want to create a previous year value measure so I did the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Actual PY = CALCULATE([Actual],DATEADD('Calendar'[Date],-1,YEAR))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;However, while this doesn't give an error, it doesn't return any value eg it is blank.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This probably has something to do with the format of the date value eg it can't find dataset rows by YYYY-MM because the previous year date is a proper date format.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;How do I get this work?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 20:13:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2013821#M44778</guid>
      <dc:creator>009co</dc:creator>
      <dc:date>2021-08-12T20:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Get previous YYYY-MM value based on existing YYYY-MM value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2014277#M44795</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="311724" data-lia-user-login="009co" class="lia-mention lia-mention-user"&gt;009co&lt;/a&gt; , As long as YYYYMM is coming from the calendar table, that should not give issue.&lt;/P&gt;
&lt;P&gt;Measure is correct&lt;/P&gt;
&lt;P&gt;Actual PY = CALCULATE([Actual],DATEADD('Calendar'[Date],-1,YEAR))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check -&lt;/P&gt;
&lt;P&gt;calendar table is marked as date table &lt;/P&gt;
&lt;P&gt;It has previous year dates in the date column. I doubt you need date PY&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So for this year date column should have date for 2020 too&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Fact Date should not have any timestamp&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why Time Intelligence Fails - Power bi 5 Savior Steps for TI: &lt;A href="https://youtu.be/OBf0rjpp5Hw" target="_blank"&gt;https://youtu.be/OBf0rjpp5Hw&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2021 03:28:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2014277#M44795</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2021-08-13T03:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Get previous YYYY-MM value based on existing YYYY-MM value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2015783#M44841</link>
      <description>&lt;P&gt;Hey thanks for answer &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Check -&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;calendar table is marked as date table -&amp;nbsp;&lt;/EM&gt;It wasn't, I didn't know this so thanks for teaching me something new. However, I am not able to mark my table as date table. I get message that claims there are gaps in dates ... I suspect it is because table doesn't have complete years even though it spans multiple years.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;It has previous year dates in the date column. I doubt you need date PY&amp;nbsp; -&amp;nbsp;&lt;/EM&gt;it did have all required dates past and present&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;The Fact Date should not have any timestamp -&amp;nbsp;&lt;/EM&gt;the table comes from SQL server db, and is formatted as text. So this might be problem too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 13 Aug 2021 18:14:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2015783#M44841</guid>
      <dc:creator>009co</dc:creator>
      <dc:date>2021-08-13T18:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: Get previous YYYY-MM value based on existing YYYY-MM value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2015819#M44842</link>
      <description>&lt;P&gt;Sometimes when this happens to me, I bypass the DATEADD() function.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll create a variable:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PY = MAX("Calendar Year Number in Date Dimension Table") - 1&lt;/P&gt;&lt;P&gt;Comment: So this takes the current Year Number in the context, and subtracts 1 manually.&lt;/P&gt;&lt;P&gt;Then in my measure:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Measure =&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE([Actual], "Calendar Year Number in Date Dimension Table" = PY)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This can often work for me, but it does require you have a Year Number in your Date Dimension.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2021 17:34:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2015819#M44842</guid>
      <dc:creator>blynchdata</dc:creator>
      <dc:date>2021-08-13T17:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Get previous YYYY-MM value based on existing YYYY-MM value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2015844#M44845</link>
      <description>&lt;P&gt;Interesting. Gave this a try but am getting following error when doing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;EM&gt;PY = MAX('Calendar'[Year]) - 1 &amp;lt;= this calculates previous year value, i formatted General with no decimals (couldn't choose Text)&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;EM&gt;Measure = CALCULATE([Actual], '&lt;SPAN&gt;Calendar&lt;/SPAN&gt;'[Year] = [PY]) &amp;lt;= this gives error:&amp;nbsp;&lt;/EM&gt;&lt;EM&gt;"A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed."&lt;/EM&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did I do this as you explained? It was clear exactly what you meant by&amp;nbsp;&lt;EM&gt;"Calendar Year Number in Date Dimension Table"&lt;/EM&gt;?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2021 17:53:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2015844#M44845</guid>
      <dc:creator>009co</dc:creator>
      <dc:date>2021-08-13T17:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: Get previous YYYY-MM value based on existing YYYY-MM value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2015902#M44848</link>
      <description>&lt;P&gt;I'm not sure there should be square brackets around the PY variable in your measure as it may think it's a column or a measure. I've confirmed this way does work for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking at some other ways that I've done this and I found that it works well, using CalculateTable() as a kind of filter within the CALCULATE() of [Actual].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Measure = CALCULATE (&lt;BR /&gt;[Actual],&lt;BR /&gt;CALCULATETABLE ( DATEADD ( 'Date Dimension'[Date_Formatted_Column], -1, YEAR ) )&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2021 18:27:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2015902#M44848</guid>
      <dc:creator>blynchdata</dc:creator>
      <dc:date>2021-08-13T18:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: Get previous YYYY-MM value based on existing YYYY-MM value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2016006#M44850</link>
      <description>&lt;P&gt;RE first suggestion, was it to create a new column with a variable and result to be returned as follows? This didn't create any errors, but was just blank:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Measure = &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;VAR &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; PY = FORMAT(DATEADD('Calendar'[Date],-1,YEAR), "YYYY")&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;RETURN &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; CALCULATE([Actual], 'Calendar'[Year] = PY)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RE second suggestion, it just returns the current year actual value:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;EM&gt;Measure = CALCULATE([Actual],CALCULATETABLE(DATEADD('Calendar'[Date],-1,YEAR)))&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This is same behaviour of my original DATEADD formula, after I marked my date table as a date table.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;Actual PY = CALCULATE([Actual],DATEADD('Calendar'[Date],-1,YEAR))&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;It is like minus 1 from year is same as current year.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 13 Aug 2021 19:58:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2016006#M44850</guid>
      <dc:creator>009co</dc:creator>
      <dc:date>2021-08-13T19:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: Get previous YYYY-MM value based on existing YYYY-MM value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2016034#M44852</link>
      <description>&lt;P&gt;Apologies, I didn't know you were trying to make a column, I thought it was a measure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will bow out here as I am unsure!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2021 20:05:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2016034#M44852</guid>
      <dc:creator>blynchdata</dc:creator>
      <dc:date>2021-08-13T20:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Get previous YYYY-MM value based on existing YYYY-MM value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2016917#M44890</link>
      <description>&lt;P&gt;My original date table and fact table relationship was based on an integer representation of a date eg 20210101 however creating a new calculated column that was a proper date in both of these tables&amp;nbsp; and using that new proper date for the relationship made time intelligence work properly.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Aug 2021 17:08:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-YYYY-MM-value-based-on-existing-YYYY-MM-value/m-p/2016917#M44890</guid>
      <dc:creator>009co</dc:creator>
      <dc:date>2021-08-15T17:08:24Z</dc:date>
    </item>
  </channel>
</rss>

