<?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: Calculate Previous Month Value But It Will Reset Every Fiscal Year in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Value-But-It-Will-Reset-Every-Fiscal/m-p/3992527#M154964</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;, Create a date table first and add following columns in it Date, Year , Month, Fiscal year, Fiscal month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then create a calulated column in main table using formula&lt;/P&gt;
&lt;P&gt;PreviousMonthValue = &lt;BR /&gt;VAR CurrentDate = 'Sales'[Date]&lt;BR /&gt;VAR CurrentFiscalYear = YEAR(CurrentDate) + IF(MONTH(CurrentDate) &amp;gt;= 5, 1, 0)&lt;BR /&gt;VAR PreviousMonth = EOMONTH(CurrentDate, -1)&lt;/P&gt;
&lt;P&gt;RETURN &lt;BR /&gt;IF (&lt;BR /&gt;MONTH(CurrentDate) = 5, &lt;BR /&gt;0, &lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM('Sales'[Value]),&lt;BR /&gt;FILTER(&lt;BR /&gt;'Sales',&lt;BR /&gt;'Sales'[Date] = PreviousMonth &amp;amp;&amp;amp;&lt;BR /&gt;(YEAR('Sales'[Date]) + IF(MONTH('Sales'[Date]) &amp;gt;= 5, 1, 0)) = CurrentFiscalYear&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jun 2024 05:49:15 GMT</pubDate>
    <dc:creator>bhanu_gautam</dc:creator>
    <dc:date>2024-06-14T05:49:15Z</dc:date>
    <item>
      <title>Calculate Previous Month Value But It Will Reset Every Fiscal Year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Value-But-It-Will-Reset-Every-Fiscal/m-p/3992472#M154961</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate your help calculating the previous month's value, but it needs to reset the previous month's value to zero if the fiscal year also changes. In the example below, the value in January 2023 is expected to be 0, and the value of the following months is already correct, but I don't know how to make a DAX with results like the table below. All I need is for the previous month's value is always reset to 0 every May, considering the fiscal year is from May to April.&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;Expected result:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2024 05:19:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Value-But-It-Will-Reset-Every-Fiscal/m-p/3992472#M154961</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-14T05:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Previous Month Value But It Will Reset Every Fiscal Year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Value-But-It-Will-Reset-Every-Fiscal/m-p/3992527#M154964</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;, Create a date table first and add following columns in it Date, Year , Month, Fiscal year, Fiscal month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then create a calulated column in main table using formula&lt;/P&gt;
&lt;P&gt;PreviousMonthValue = &lt;BR /&gt;VAR CurrentDate = 'Sales'[Date]&lt;BR /&gt;VAR CurrentFiscalYear = YEAR(CurrentDate) + IF(MONTH(CurrentDate) &amp;gt;= 5, 1, 0)&lt;BR /&gt;VAR PreviousMonth = EOMONTH(CurrentDate, -1)&lt;/P&gt;
&lt;P&gt;RETURN &lt;BR /&gt;IF (&lt;BR /&gt;MONTH(CurrentDate) = 5, &lt;BR /&gt;0, &lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM('Sales'[Value]),&lt;BR /&gt;FILTER(&lt;BR /&gt;'Sales',&lt;BR /&gt;'Sales'[Date] = PreviousMonth &amp;amp;&amp;amp;&lt;BR /&gt;(YEAR('Sales'[Date]) + IF(MONTH('Sales'[Date]) &amp;gt;= 5, 1, 0)) = CurrentFiscalYear&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2024 05:49:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Value-But-It-Will-Reset-Every-Fiscal/m-p/3992527#M154964</guid>
      <dc:creator>bhanu_gautam</dc:creator>
      <dc:date>2024-06-14T05:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Previous Month Value But It Will Reset Every Fiscal Year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Value-But-It-Will-Reset-Every-Fiscal/m-p/3992819#M154980</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Previous Month Value = 
IF ( 
    ISINSCOPE ( 'Date'[Fiscal Year Number] ), -- Removes the Grand Total
    IF ( 
        MAX ( 'Date'[Fiscal Month Number] ) = 1,
        0, -- Just show 0 when month is May
        CALCULATE ( 
            [Total Sales],
            DATEADD ( 'Date'[Date], -1, MONTH ),
            VALUES ( 'Date'[Fiscal Year] ) -- Only perform DATEADD for current  year, 
                                           -- returns NULL for first month next year
        )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can improve the above code with some variables for readability&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Previous Month Value 2 = 
VAR IsFirstMonth = 
    MAX ( 'Date'[Fiscal Month Number] ) = 1
VAR GroupingByYear = 
    ISINSCOPE ( 'Date'[Fiscal Year Number] )
VAR PreviousMonthValue = 
    CALCULATE ( 
        [Total Sales],
        DATEADD ( 'Date'[Date], -1, MONTH ),
        VALUES ( 'Date'[Fiscal Year] )
    )
VAR Result = 
    IF ( 
        GroupingByYear,
        IF ( IsFirstMonth, 0, PreviousMonthValue )
    )
RETURN 
    Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can also use OFFSET&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Previous Month Value OFFSET = 
VAR IsFirstMonth = 
    MAX ( 'Date'[Fiscal Month Number] ) = 1
VAR GroupingByYear = 
    ISINSCOPE ( 'Date'[Fiscal Year Number] )
VAR PreviousMonthValue = 
    CALCULATE ( 
        [Total Sales],
        OFFSET ( 
            -1, 
            ALL ( 'Date'[Month], 'Date'[Fiscal Month Number], 'Date'[Fiscal Year Number] ), 
            ORDERBY ( 'Date'[Fiscal Month Number], ASC ),
            PARTITIONBY ( 'Date'[Fiscal Year Number] )
        )
    )
VAR Result = 
    IF ( 
        GroupingByYear,
        IF ( IsFirstMonth, 0, PreviousMonthValue )
    )
RETURN 
    Result&lt;/LI-CODE&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2024 07:57:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Value-But-It-Will-Reset-Every-Fiscal/m-p/3992819#M154980</guid>
      <dc:creator>AntrikshSharma</dc:creator>
      <dc:date>2024-06-14T07:57:31Z</dc:date>
    </item>
  </channel>
</rss>

