<?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: Sameperiodlastyear - Leap Year in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-Leap-Year/m-p/943839#M10164</link>
    <description>By the way... You should never rely on the automatic Date table that PBI creates for you. NEVER. You should always create your own Date table according to the rules for such tables.</description>
    <pubDate>Sat, 22 Feb 2020 13:53:36 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-02-22T13:53:36Z</dc:date>
    <item>
      <title>Sameperiodlastyear - Leap Year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-Leap-Year/m-p/943125#M10105</link>
      <description>&lt;P&gt;-I have a report with 3 columns (Date, System Sales, System Sales LY)&lt;/P&gt;&lt;P&gt;-The goal is to compare Day to Day Sales from this year to Last year.&amp;nbsp;&lt;/P&gt;&lt;P&gt;-I have used the basic DAX for the Sales calculation&amp;nbsp;&lt;/P&gt;&lt;P&gt;&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; System Sales = SUM(Salestable[Total])&lt;/P&gt;&lt;P&gt;&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; System Sales LY = CALCULATE ([System Sales], SAMEPERIODLASTYEAR('DateDimension'[Date])&lt;/P&gt;&lt;P&gt;-My 'Sales table' is joined to the 'Date Dimension table' on SalesDate and Date respectively.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-My problem is Feb2020. It is a leap year. So for &lt;STRONG&gt;LY calculation&lt;/STRONG&gt;, DAX is auto-populating for '2/29'. Even though there is no '2/29' in 2019. (Please see the attached screenshot for reference.).&amp;nbsp;&lt;/P&gt;&lt;P&gt;- In LY System Sales column, for the '2/29' should be empty, however, it shows the value of '2/28'. (In this case, you can see the value $449,003.6 repeating twice)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I fix it? Can you please help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2020 16:56:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-Leap-Year/m-p/943125#M10105</guid>
      <dc:creator>Sal1037</dc:creator>
      <dc:date>2020-02-21T16:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Sameperiodlastyear - Leap Year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-Leap-Year/m-p/943197#M10115</link>
      <description>&lt;P&gt;Im curious if you would instead use the DATEADD opposed to SPLY if it would be any different. I have had issues with SPLY in the past and since have used DATEADD instead.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lets try this first - as SPLY may have logic built in for leap year.. which i suppose folks off of leap year would like to know what they made last year if there was a leap year for the 28th... anywho this is a silly oversight imo by microsoft possibly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Double check your data to ensure there are no values for 02/29/2019 - I understand this date technically doesnt exist..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anywho -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Rev. LY = 
CALCULATE( [TOTAL REV], DATEADD( dDATES, -1 , YEAR) )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;let me know if there are any differences.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2020 17:31:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-Leap-Year/m-p/943197#M10115</guid>
      <dc:creator>AlexAlberga727</dc:creator>
      <dc:date>2020-02-21T17:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: Sameperiodlastyear - Leap Year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-Leap-Year/m-p/943247#M10118</link>
      <description>&lt;P&gt;Hi Alex, Thanks for the quick response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-I have tried the DATEADD. It gave me the same outcome as the 'Sameperiodlastyear'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;-I called it 'SystemSales LY_2'. The DAX formula is: System Sales LY_2 = CALCULATE([System Sales],DATEADD(DateDimension[Date],-1,YEAR))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Please see the attached screenshot for reference.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;img /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;-Just to be sure, I have checked both 'Sales table' and 'Date dimension table. Neither tables have the date '2/29/2019' as it does not exist. Thus there is no data associated for that date '2/29/2019'. However, I believe due to the leap year of 2/29/2020, PBI is auto-populating value for it.&amp;nbsp;&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, 21 Feb 2020 18:08:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-Leap-Year/m-p/943247#M10118</guid>
      <dc:creator>Sal1037</dc:creator>
      <dc:date>2020-02-21T18:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sameperiodlastyear - Leap Year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-Leap-Year/m-p/943828#M10161</link>
      <description>This is the correct behaviour. This is how it should be. The last day of the month is compared to the last day of the month of the prior year. This is what time-intel means. If you want to override this, you'll need to write your own piece of logic that'll deal with Feb 29. Rather easy to do.</description>
      <pubDate>Sat, 22 Feb 2020 13:31:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-Leap-Year/m-p/943828#M10161</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-22T13:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: Sameperiodlastyear - Leap Year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-Leap-Year/m-p/943831#M10162</link>
      <description>&lt;LI-CODE lang="markup"&gt;Sales PY :=
	if( hasonevalue(DateDimension[Date]),
		var __currentDate = max(DateDimension[Date])
		var __shouldCalculate =
			month(__currentDate) &amp;lt;&amp;gt; 2
			&amp;amp;&amp;amp; day(__currentDate) &amp;lt;&amp;gt; 29
		var __result =
			if(__shouldCalculate,
				CALCULATE(
					[System Sales],
					DATEADD(DateDimension[Date],-1,YEAR)
				)
			)
		return
			__result
	)&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 22 Feb 2020 13:36:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-Leap-Year/m-p/943831#M10162</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-22T13:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sameperiodlastyear - Leap Year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-Leap-Year/m-p/943839#M10164</link>
      <description>By the way... You should never rely on the automatic Date table that PBI creates for you. NEVER. You should always create your own Date table according to the rules for such tables.</description>
      <pubDate>Sat, 22 Feb 2020 13:53:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-Leap-Year/m-p/943839#M10164</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-22T13:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: Sameperiodlastyear - Leap Year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-Leap-Year/m-p/3744099#M146004</link>
      <description>&lt;P&gt;A possible option for this is to create a calculated column in your date table to flaf Feb 29 as a Leap Day. Then use the code below for setting last year numbers to 0 for Feb 29 .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR LeapDay = IF( HASONEVALUE( 'Date'[Date] ), MAXA( 'Date'[LeapDay] ) )&lt;BR /&gt;RETURN&lt;BR /&gt;SWITCH(&lt;BR /&gt;TRUE( ),&lt;BR /&gt;LeapDay = 1, 0,&lt;BR /&gt;CALCULATE( Sales , SAMEPERIODLASTYEAR( 'Date'[Date] ))&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2024 20:05:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-Leap-Year/m-p/3744099#M146004</guid>
      <dc:creator>Bankyiie</dc:creator>
      <dc:date>2024-03-05T20:05:13Z</dc:date>
    </item>
  </channel>
</rss>

