<?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: Quantity of the last 12 months in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quantity-of-the-last-12-months/m-p/3835494#M149964</link>
    <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="501067" data-lia-user-login="Sahir_Maharaj" class="lia-mention lia-mention-user"&gt;Sahir_Maharaj&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this looks great! Is there a reason to use EDATE instead of DATEADD ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After a night of sleep I also found a solution.&lt;/P&gt;&lt;P&gt;But I have to add a column in my calendar table called [Twelve months before] and then go with&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;VAR _latestMonth =&amp;nbsp;&lt;BR /&gt;MAX(DIM_Calendar[EOM])&lt;BR /&gt;&lt;BR /&gt;VAR _latestMonthMinus12 =&amp;nbsp;&lt;BR /&gt;MAX(DIM_Calendar[Twelve months before])&lt;BR /&gt;&lt;BR /&gt;VAR _inLast12Months =&amp;nbsp;&lt;BR /&gt;FILTER(&lt;BR /&gt;ALL(DIM_Calendar)&lt;BR /&gt;, DIM_Calendar[Date] &amp;gt;= _latestMonthMinus12 &amp;amp;&amp;amp; DIM_Calendar[Date] &amp;lt;= _latestMonth&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;&lt;SPAN&gt; SUM(FACTS[QUANTITY])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; , _inLast12Months&lt;/SPAN&gt;&lt;BR /&gt;)&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Anyway your solutuion seems to be more efficient&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Sat, 13 Apr 2024 11:14:46 GMT</pubDate>
    <dc:creator>Lanceometer</dc:creator>
    <dc:date>2024-04-13T11:14:46Z</dc:date>
    <item>
      <title>Quantity of the last 12 months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quantity-of-the-last-12-months/m-p/3834257#M149914</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi folks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to create a Complaint ratio for customer complaints.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For that I want to take the amount of complaints and divide it by the average sales quantity per month of the last 12 months from the latest selected month.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But I am already failing in calculating the Quantity of the last 12 month (referring to the latest selected month)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have a Fact Table: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;FACT_DT, QUANTITY, PRODUCT_ID &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2023-01-31,146,a &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2023-02-28,546,a &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2023-03-31,651,a &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2023-04-30,713,a &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2023-05-31,358,a &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2023-01-31,444,b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2023-02-28,512,b &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2023-03-31,43,b &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2023-04-30,4525,&lt;/SPAN&gt;&lt;SPAN&gt;b &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2023-05-31,45,&lt;/SPAN&gt;&lt;SPAN&gt;b &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and so on &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My Date Table is DIM_Calendar and has the Columns Date (e.g. "21.03.2023") and Month (e.g. "Mar 2023") &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have a Dimension Table for the Products&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In my dashbard there is a slicer on the "Month" field of the DIM_Calendar table. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have a bar chart with "Product" on the Y-axis. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;On the X-axis it should show the quantity of the last 12 months from the latest selected month. so i select in my Slicer "Feb 2023" and "Mar 2023", &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to see the sum of the quantity from "Apr 2022"+"Jun 2022"+"Jul 2022"+"Aug 2022"+"Sep 2022"+"Oct 2022"+"Nov 2022"+"Dec 2022"+"Jan 2023"+"Feb 2023"+"Mar 2023"&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 14:08:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quantity-of-the-last-12-months/m-p/3834257#M149914</guid>
      <dc:creator>Lanceometer</dc:creator>
      <dc:date>2024-04-12T14:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: Quantity of the last 12 months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quantity-of-the-last-12-months/m-p/3834756#M149938</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="723485" data-lia-user-login="Lanceometer" class="lia-mention lia-mention-user"&gt;Lanceometer&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please try the following:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Quantity Last 12 Months = 
VAR LatestMonthSelected = MAX('DIM_Calendar'[Date])
VAR StartDate = EDATE(LatestMonthSelected, -12)
RETURN
CALCULATE(
    SUM('FACT_DT'[QUANTITY]),
    'FACT_DT'[FACT_DT] &amp;gt; StartDate &amp;amp;&amp;amp; 'FACT_DT'[FACT_DT] &amp;lt;= LatestMonthSelected
)
&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 12 Apr 2024 20:14:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quantity-of-the-last-12-months/m-p/3834756#M149938</guid>
      <dc:creator>Sahir_Maharaj</dc:creator>
      <dc:date>2024-04-12T20:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: Quantity of the last 12 months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quantity-of-the-last-12-months/m-p/3835494#M149964</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="501067" data-lia-user-login="Sahir_Maharaj" class="lia-mention lia-mention-user"&gt;Sahir_Maharaj&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this looks great! Is there a reason to use EDATE instead of DATEADD ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After a night of sleep I also found a solution.&lt;/P&gt;&lt;P&gt;But I have to add a column in my calendar table called [Twelve months before] and then go with&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;VAR _latestMonth =&amp;nbsp;&lt;BR /&gt;MAX(DIM_Calendar[EOM])&lt;BR /&gt;&lt;BR /&gt;VAR _latestMonthMinus12 =&amp;nbsp;&lt;BR /&gt;MAX(DIM_Calendar[Twelve months before])&lt;BR /&gt;&lt;BR /&gt;VAR _inLast12Months =&amp;nbsp;&lt;BR /&gt;FILTER(&lt;BR /&gt;ALL(DIM_Calendar)&lt;BR /&gt;, DIM_Calendar[Date] &amp;gt;= _latestMonthMinus12 &amp;amp;&amp;amp; DIM_Calendar[Date] &amp;lt;= _latestMonth&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;&lt;SPAN&gt; SUM(FACTS[QUANTITY])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; , _inLast12Months&lt;/SPAN&gt;&lt;BR /&gt;)&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Anyway your solutuion seems to be more efficient&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 13 Apr 2024 11:14:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quantity-of-the-last-12-months/m-p/3835494#M149964</guid>
      <dc:creator>Lanceometer</dc:creator>
      <dc:date>2024-04-13T11:14:46Z</dc:date>
    </item>
  </channel>
</rss>

