<?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: DAX measure that calculates sales for the last 12 months from a filter in the slicer in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-that-calculates-sales-for-the-last-12-months-from-a/m-p/3728712#M145282</link>
    <description>&lt;P&gt;Please provide sample data that covers your issue or question &lt;STRONG&gt;completely&lt;/STRONG&gt;, in a &lt;STRONG&gt;usable&lt;/STRONG&gt; format (not as a screenshot).&lt;BR /&gt;&lt;BR /&gt;Do not include sensitive information or anything not related to the issue or question. &lt;BR /&gt;&lt;BR /&gt;If you are unsure how to upload data please refer to &lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;Want faster answers? &lt;A href="https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Feb 2024 21:15:41 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2024-02-27T21:15:41Z</dc:date>
    <item>
      <title>DAX measure that calculates sales for the last 12 months from a filter in the slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-that-calculates-sales-for-the-last-12-months-from-a/m-p/3727459#M145209</link>
      <description>&lt;P&gt;Hi friends!&lt;/P&gt;&lt;P&gt;In Power BI, I need a DAX measure that calculates sales for the last 12 months from a filter in the slicer. For example, if you filter the month "01/2024" in the slicer, I need it to return sales from "02/2023" to "01/2024". I intend to place this measurement in a bar graph that will always return 12 columns, one for each month.&lt;/P&gt;&lt;P&gt;I have a calendar table with dates and a column called "Month/Year" (MM/YYYY) which is related to the sales table by date.&lt;/P&gt;&lt;P&gt;I have the DAX measure below, but it don´t calculate last 12 month when the slicer is filtered.&lt;/P&gt;&lt;LI-CODE lang="css"&gt;Last 12M = 
IF(
    ISFILTERED('dCalendar'),

    CALCULATE(
        [Sales US$],
        FILTER(
            'dCalendar',
            'dCalendar'[Date] &amp;gt;= EOMONTH(TODAY(), -12)+1 &amp;amp;&amp;amp; 'dCalendar'[Date] &amp;lt;= EOMONTH(TODAY(),0)
        )
    ),

    [Sales US$]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 12:04:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-that-calculates-sales-for-the-last-12-months-from-a/m-p/3727459#M145209</guid>
      <dc:creator>Rai_BI</dc:creator>
      <dc:date>2024-02-27T12:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: DAX measure that calculates sales for the last 12 months from a filter in the slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-that-calculates-sales-for-the-last-12-months-from-a/m-p/3728712#M145282</link>
      <description>&lt;P&gt;Please provide sample data that covers your issue or question &lt;STRONG&gt;completely&lt;/STRONG&gt;, in a &lt;STRONG&gt;usable&lt;/STRONG&gt; format (not as a screenshot).&lt;BR /&gt;&lt;BR /&gt;Do not include sensitive information or anything not related to the issue or question. &lt;BR /&gt;&lt;BR /&gt;If you are unsure how to upload data please refer to &lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;Want faster answers? &lt;A href="https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 21:15:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-that-calculates-sales-for-the-last-12-months-from-a/m-p/3728712#M145282</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-02-27T21:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: DAX measure that calculates sales for the last 12 months from a filter in the slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-that-calculates-sales-for-the-last-12-months-from-a/m-p/3729675#M145322</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="570958" data-lia-user-login="Rai_BI" class="lia-mention lia-mention-user"&gt;Rai_BI&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Create a calculation sheet to get all the dates you need.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Table =
DISTINCT('financials'[Date])&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;2. Create a slicer using dates from the calculation table.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;3. Create a measure to determine whether the date in the table is within the twelve months before the selected date.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure =
VAR _select = SELECTEDVALUE('Table'[Date])
RETURN
IF(_select &amp;gt;= MAX('financials'[Date]) &amp;amp;&amp;amp; _select &amp;lt;= MAX('financials'[Date]) + 365,1,0)&lt;/LI-CODE&gt;
&lt;P&gt;4. Place the measure value in the filters pane of the visual object to be displayed, and filter the data with a measure value equal to 1.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;5. The final result is shown in the figure below.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe your date data needs to be further processed using functions such as EOMONTH, but the overall idea is this. First create a table that has no relationship with the original table to be used as a slicer, and then use the measurement value to filter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your Current Period does not refer to this, please clarify in a follow-up reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Clara Gong&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>Wed, 28 Feb 2024 06:43:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-that-calculates-sales-for-the-last-12-months-from-a/m-p/3729675#M145322</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-02-28T06:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: DAX measure that calculates sales for the last 12 months from a filter in the slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-that-calculates-sales-for-the-last-12-months-from-a/m-p/3731277#M145415</link>
      <description>&lt;P&gt;Thank you ! Your solution is very good. But found this video in the link&amp;nbsp;&lt;A href="https://www.youtube.com/watch?v=d8Rm7dwM6gc&amp;amp;t=1053s" target="_blank"&gt;Show last 6 months based on user single slicer selection (youtube.com)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 17:23:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-that-calculates-sales-for-the-last-12-months-from-a/m-p/3731277#M145415</guid>
      <dc:creator>Rai_BI</dc:creator>
      <dc:date>2024-02-28T17:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: DAX measure that calculates sales for the last 12 months from a filter in the slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-that-calculates-sales-for-the-last-12-months-from-a/m-p/5231028#M188234</link>
      <description>&lt;P class=""&gt;The fix in the accepted solution is correct , replacing TODAY() with MAX('dCalendar'[Date]) respects the slicer context instead of ignoring it.&lt;/P&gt;&lt;P class=""&gt;Clean pattern for rolling 12 months from slicer:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;Last 12M Sales =&lt;BR /&gt;VAR _maxDate = MAX('dCalendar'[Date])&lt;BR /&gt;VAR _minDate = EDATE(_maxDate, -12) + 1&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;[Sales US$],&lt;BR /&gt;DATESBETWEEN('dCalendar'[Date], _minDate, _maxDate)&lt;BR /&gt;)&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P class=""&gt;DATESBETWEEN is cleaner than FILTER(ALL(...)) here because it handles the date table relationship automatically.&lt;/P&gt;&lt;P class=""&gt;For reports where users need to compare rolling 12M vs prior 12M themselves (without the developer creating a separate measure each time), &lt;STRONG&gt;Flexa Tables&lt;/STRONG&gt; on AppSource lets Finance users select the two periods to compare directly in the published report&amp;nbsp; period comparison becomes self-service&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2026 03:57:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-that-calculates-sales-for-the-last-12-months-from-a/m-p/5231028#M188234</guid>
      <dc:creator>PBIdashboards</dc:creator>
      <dc:date>2026-06-24T03:57:58Z</dc:date>
    </item>
  </channel>
</rss>

