<?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: Prior Year Value not calculating correctly in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Prior-Year-Value-not-calculating-correctly/m-p/4001939#M155982</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&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;&amp;nbsp;. Was able to get it to work after adding SWITCH for the PY measure as well.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;However, curious to know why just using SAMEPERIODLASTYEAR does not work in my orginal PY measure.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Jun 2024 12:15:42 GMT</pubDate>
    <dc:creator>VickyDev18</dc:creator>
    <dc:date>2024-06-20T12:15:42Z</dc:date>
    <item>
      <title>Prior Year Value not calculating correctly</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Prior-Year-Value-not-calculating-correctly/m-p/4000459#M155826</link>
      <description>&lt;P&gt;Can anyone help explain why the Amount_PY measure is not returning the correct value in the Full Year scenario below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is summing up amount across all years but I'm just not able to figure out why.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DEFINE
    MEASURE __Metrics[Amount] =
        SWITCH (
            SELECTEDVALUE ( __Period[Period Name] ),
            "Month",
                CALCULATE (
                    SUM ( Financials[Accounting Currency Amount Signed] ),
                    DATESMTD ( 'AccountingCalendar'[Date] )
                ),
            "Year-To-Date",
                CALCULATE (
                    SUM ( Financials[Accounting Currency Amount Signed] ),
                    DATESYTD ( 'AccountingCalendar'[Date] )
                ),
            "Full Year",
                CALCULATE (
                    SUM ( Financials[Accounting Currency Amount Signed] ),
                    ALLEXCEPT ( AccountingCalendar, AccountingCalendar[Year] )
                ),
            SUM ( Financials[Accounting Currency Amount Signed] )
        )
    
    MEASURE __Metrics[Amount_AC] =
        CALCULATE ( [Amount], Scenarios[Scenario Type] = "Actuals" )
    
    MEASURE __Metrics[Amount_PY] =
        CALCULATE ( [Amount_AC], SAMEPERIODLASTYEAR ( AccountingCalendar[Date] ) )

EVALUATE
SUMMARIZECOLUMNS (
    AccountingCalendar[Year],
    AccountingCalendar[Calendar Month],
    __Period[Period ID],
    __Period[Period Name],
    TREATAS ( { "Latest" }, AccountingCalendar[Month Type] ),
    TREATAS ( { 2022, 2023, 2024 }, AccountingCalendar[Year] ),
    "Amount_AC", [Amount_AC],
    "Amount_PY", [Amount_PY]
)
ORDER BY
    AccountingCalendar[Year] ASC,
    __Period[Period ID] ASC&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: The Month Type essentially filters the latest completed month within each year.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2024 15:56:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Prior-Year-Value-not-calculating-correctly/m-p/4000459#M155826</guid>
      <dc:creator>VickyDev18</dc:creator>
      <dc:date>2024-06-19T15:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Prior Year Value not calculating correctly</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Prior-Year-Value-not-calculating-correctly/m-p/4000467#M155827</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="509497" data-lia-user-login="VickyDev18" class="lia-mention lia-mention-user"&gt;VickyDev18&lt;/a&gt; , you also need a switch for the previous measure &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please refer example measure, which you have use in Switch for PY&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will work for the month and the same period&lt;/P&gt;
&lt;P&gt;Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Last year ytd&lt;/P&gt;
&lt;P&gt;Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Last year full &lt;BR /&gt;Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Last Year full = CALCULATE(SUM(Sales[Sales Amount]),previousyear('Date'[Date]))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Time Intelligence, Part of learn Power BI &lt;A href="https://youtu.be/cN8AO3_vmlY?t=27510" target="_blank"&gt;https://youtu.be/cN8AO3_vmlY?t=27510&lt;/A&gt;&lt;BR /&gt;Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period, &lt;BR /&gt;Custom Period till date: &lt;A href="https://youtu.be/aU2aKbnHuWs&amp;amp;t=145s" target="_blank"&gt;https://youtu.be/aU2aKbnHuWs&amp;amp;t=145s&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2024 16:10:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Prior-Year-Value-not-calculating-correctly/m-p/4000467#M155827</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2024-06-19T16:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Prior Year Value not calculating correctly</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Prior-Year-Value-not-calculating-correctly/m-p/4001939#M155982</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&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;&amp;nbsp;. Was able to get it to work after adding SWITCH for the PY measure as well.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;However, curious to know why just using SAMEPERIODLASTYEAR does not work in my orginal PY measure.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 12:15:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Prior-Year-Value-not-calculating-correctly/m-p/4001939#M155982</guid>
      <dc:creator>VickyDev18</dc:creator>
      <dc:date>2024-06-20T12:15:42Z</dc:date>
    </item>
  </channel>
</rss>

