<?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: MTD LY using Month as Filter Context in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MTD-LY-using-Month-as-Filter-Context/m-p/926134#M9390</link>
    <description>&lt;P&gt;Yes, that's how it works and yes it can be frustrating. The month in your filter is actually using the last day of the month in the filter context (from the calendar table) hence the problem. You need a way to detect the last date with sales in the current month. I like to do this with a calculated column in the calendar table. You could call it something like "Past Date" and return true or false. If you then filter on this column, the calendar filter context will crab the last date with sales, and that should fix the last year data.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 08 Feb 2020 21:25:10 GMT</pubDate>
    <dc:creator>MattAllington</dc:creator>
    <dc:date>2020-02-08T21:25:10Z</dc:date>
    <item>
      <title>MTD LY using Month as Filter Context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MTD-LY-using-Month-as-Filter-Context/m-p/926112#M9389</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use month as filter conext for my table in power pivot and compare MTD sales TY vs MTD sales last year. For example today is Feb 8 and I want to show MTD sales for this year (currently using SUM(sales) and month as the filter context as my calendar table updates only to the max sales date). Where I am running into issues is MTD LY as it is totaling the whole month of last year (not to Feb 8, 2019). I do not want to put individual dates on the table to solve for this. Any help would be appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 08 Feb 2020 19:37:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MTD-LY-using-Month-as-Filter-Context/m-p/926112#M9389</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-08T19:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: MTD LY using Month as Filter Context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MTD-LY-using-Month-as-Filter-Context/m-p/926134#M9390</link>
      <description>&lt;P&gt;Yes, that's how it works and yes it can be frustrating. The month in your filter is actually using the last day of the month in the filter context (from the calendar table) hence the problem. You need a way to detect the last date with sales in the current month. I like to do this with a calculated column in the calendar table. You could call it something like "Past Date" and return true or false. If you then filter on this column, the calendar filter context will crab the last date with sales, and that should fix the last year data.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Feb 2020 21:25:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MTD-LY-using-Month-as-Filter-Context/m-p/926134#M9390</guid>
      <dc:creator>MattAllington</dc:creator>
      <dc:date>2020-02-08T21:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: MTD LY using Month as Filter Context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MTD-LY-using-Month-as-Filter-Context/m-p/926241#M9397</link>
      <description>&lt;P&gt;Try a filter of day&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last year MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)), day('Date'[Date])&amp;lt;=day(today()))&lt;/LI-CODE&gt;&lt;P&gt;I have not tested it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.&lt;BR /&gt;In case it does not help, please provide additional information and mark me with @ &lt;/STRONG&gt;&lt;BR /&gt;Thanks. &lt;STRONG&gt;My Recent Blogs -&lt;/STRONG&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/Decoding-Direct-Query-in-Power-BI-Part-1-Time-Intelligence-in/ba-p/922885" target="_blank"&gt;Decoding Direct Query - Time Intelligence&lt;/A&gt;, &lt;A href="https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners/ba-p/890814" target="_blank"&gt;Winner Coloring on MAP&lt;/A&gt;, &lt;A href="https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970" target="_blank"&gt;HR Analytics&lt;/A&gt;, &lt;A href="https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p/881739" target="_blank"&gt;Power BI Working with Non-Standard Time&lt;/A&gt;And &lt;A href="https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601" target="_blank"&gt;Comparing Data Across Date Ranges&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.linkedin.com/in/amitchandak78/" target="_blank"&gt;Connect on Linkedin&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Feb 2020 13:47:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MTD-LY-using-Month-as-Filter-Context/m-p/926241#M9397</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-02-09T13:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: MTD LY using Month as Filter Context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MTD-LY-using-Month-as-Filter-Context/m-p/926400#M9407</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please use the below formula :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SAME PERIOD LAST YEAR  = 
VAR DataMaxDate =
    CALCULATE ( MAX ( 'Table'[Date.Date].[Date] ), ALL ('Table' ) )
RETURN
    CALCULATE (
        [YTD Sales],
        SAMEPERIODLASTYEAR (
            INTERSECT (
                VALUES ('Table'[Date.Date].[Date] ),
                DATESBETWEEN ( 'Table'[Date.Date], BLANK (), DataMaxDate )
            )
        )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE : make sure to change Date column to date type otherwise you will end up with the same issue you are facing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Gaurav Raj Singh&lt;/P&gt;&lt;P&gt;LinkedIN :&amp;nbsp;&lt;A href="https://www.linkedin.com/in/gauravrajsingh/" target="_blank" rel="noopener"&gt;https://www.linkedin.com/in/gauravrajsingh/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 01:47:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MTD-LY-using-Month-as-Filter-Context/m-p/926400#M9407</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-10T01:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: MTD LY using Month as Filter Context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MTD-LY-using-Month-as-Filter-Context/m-p/926565#M9414</link>
      <description>&lt;P&gt;Thanks! That worked!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 05:19:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MTD-LY-using-Month-as-Filter-Context/m-p/926565#M9414</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-10T05:19:17Z</dc:date>
    </item>
  </channel>
</rss>

