<?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() doesnot return the calculation for the last year but the last two years in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-doesnot-return-the-calculation-for-the-last/m-p/3682308#M143010</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="685204" data-lia-user-login="Laughter" class="lia-mention lia-mention-user"&gt;Laughter&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your statement, I think your issue may be that your measure in calculation group will return the data in two years instead of one year.&lt;/P&gt;
&lt;P&gt;As far as I know, the result it result is based on the measure you use in SELECTEDMEASURE().&lt;/P&gt;
&lt;P&gt;So we need more information about your measure.&lt;/P&gt;
&lt;P&gt;Please share a sample file with us and show us a screenshot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Feb 2024 08:14:14 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-02-06T08:14:14Z</dc:date>
    <item>
      <title>Sameperiodlastyear() doesnot return the calculation for the last year but the last two years</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-doesnot-return-the-calculation-for-the-last/m-p/3678436#M142828</link>
      <description>&lt;P&gt;Dear community:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I calculate the unit price using power bi sameperiodlastyear() , I have a small database it contains only sales of 2022 till today which is feb 2024. and I want to know yoy% , the returned calculation is not correct, I found out the reason is, sameperiodlastyear() take 2022 and 2023 two years sale data to calculate unit price instead of using only 2023 year's data , why?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;this is my code for yoy% in calculation group&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;this is my YoY% measure using calculation group:DIVIDE( CALCULATE( SELECTEDMEASURE(), FILTER( DateTable, INT( 'DateTable'[Year] ) = YEAR( MAX('T sales'[invoice date]) ) ) ), CALCULATE( SELECTEDMEASURE( ), SAMEPERIODLASTYEAR(DateTable[date]) ) )-1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;when i using this measure, it compares the unit price of 2024 with 2022 and 2023 data together, ( this means it uses total sales of 2022+2023 divide total quantity of 2022+2023, which is incorrect.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I think I don't understand the behaviour of sameperiodelastyear() quite well.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Feb 2024 13:12:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-doesnot-return-the-calculation-for-the-last/m-p/3678436#M142828</guid>
      <dc:creator>Laughter</dc:creator>
      <dc:date>2024-02-04T13:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Sameperiodlastyear() doesnot return the calculation for the last year but the last two years</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-doesnot-return-the-calculation-for-the-last/m-p/3678469#M142830</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="685204" data-lia-user-login="Laughter" class="lia-mention lia-mention-user"&gt;Laughter&lt;/a&gt;&amp;nbsp;You may find this helpful - &lt;A href="https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008" target="_blank"&gt;https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also:&lt;/P&gt;
&lt;P&gt;&lt;div data-video-id="https://youtu.be/nUZPk7lpe_Q" data-video-remote-vid="https://youtu.be/nUZPk7lpe_Q" class="lia-video-container lia-media-is-center lia-media-size-medium"&gt;&lt;iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FnUZPk7lpe_Q%3Ffeature%3Doembed&amp;amp;display_name=YouTube&amp;amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DnUZPk7lpe_Q&amp;amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FnUZPk7lpe_Q%2Fhqdefault.jpg&amp;amp;type=text%2Fhtml&amp;amp;schema=youtube" allowfullscreen="" style="max-width: 100%"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Feb 2024 14:09:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-doesnot-return-the-calculation-for-the-last/m-p/3678469#M142830</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2024-02-04T14:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: Sameperiodlastyear() doesnot return the calculation for the last year but the last two years</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-doesnot-return-the-calculation-for-the-last/m-p/3678480#M142833</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="685204" data-lia-user-login="Laughter" class="lia-mention lia-mention-user"&gt;Laughter&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;You need to reference a measure with the first period&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR Period1 = 
  CALCULATE( 
    SELECTEDMEASURE(), 
    FILTER( DateTable, year( 'DateTable'[date] ) = YEAR( MAX('T sales'[invoice date]) ) ) 
)
VAR Period2 = 
  CALCULATE( 
    Period1, 
    SAMEPERIODLASTYEAR(DateTable[date]) 
)
RETURN
  DIVIDE( Period1, Period2) -1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;You can write periodd2 as this, if you prefer&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR Period2 = 
  CALCULATE( 
    Period1, 
    dateadd(DateTable[date],-1,year) 
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can find usefull information here:&amp;nbsp;&lt;A href="https://www.sqlbi.com/articles/differences-between-dateadd-and-parallelperiod-in-dax/" target="_blank"&gt;Differences between DATEADD and PARALLELPERIOD in DAX - SQLBI&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Feb 2024 14:25:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-doesnot-return-the-calculation-for-the-last/m-p/3678480#M142833</guid>
      <dc:creator>latimeria</dc:creator>
      <dc:date>2024-02-04T14:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Sameperiodlastyear() doesnot return the calculation for the last year but the last two years</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-doesnot-return-the-calculation-for-the-last/m-p/3682308#M143010</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="685204" data-lia-user-login="Laughter" class="lia-mention lia-mention-user"&gt;Laughter&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your statement, I think your issue may be that your measure in calculation group will return the data in two years instead of one year.&lt;/P&gt;
&lt;P&gt;As far as I know, the result it result is based on the measure you use in SELECTEDMEASURE().&lt;/P&gt;
&lt;P&gt;So we need more information about your measure.&lt;/P&gt;
&lt;P&gt;Please share a sample file with us and show us a screenshot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 08:14:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sameperiodlastyear-doesnot-return-the-calculation-for-the-last/m-p/3682308#M143010</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-02-06T08:14:14Z</dc:date>
    </item>
  </channel>
</rss>

