<?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: Aggregated Current Year vs. Previous Year with Date Range Slicer in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregated-Current-Year-vs-Previous-Year-with-Date-Range-Slicer/m-p/755539#M2976</link>
    <description>&lt;P&gt;IT granted me access to share via OneDrive:&lt;/P&gt;&lt;P&gt;&lt;A title="Sample PBIX" href="https://hagercompanies-my.sharepoint.com/:u:/g/personal/cisenberg_hagerco_com/EZrgNEQwkm5Dv9H2kPEmLXkBU3MbJAPjkj0HGlnxepT8sw?e=LJWhSu" target="_self"&gt;Sample PBIX&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That being said, I believe that I've figured out the problem and solution in the interim. Long story short, I actually used my DateDim table to filter the canvas instead of INVOICE_DATE, and I modified my measure to simply use SAMEPERIODLASTYEAR(); all of the preliminary validation I've done confirms that this approach works. This was infinitely easier than the approaches I've tried before, and it's a good example of why you want to appropriately model your data and then use the model properly!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The detailed explanation is that when I used INVOICE_DATE as a filter (and SALES_CCN), since these fields are both in the same table as my [Invoiced Sales $], my measure invoked DAX Autoexists via the CALCULATE() function. Effectively, this excluded sales of items in 2018 that were not sold in 2019, thus why we see no PY sales in the old method. Per the excellent article I referenced in my original post, there is no way to bypass Autoexist other than to filter a table using fields from other tables, and for that, you need a proper star schema.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate the help on this; creating the sample file got me thinking in the right direction.&lt;/P&gt;</description>
    <pubDate>Thu, 01 Aug 2019 18:43:44 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-08-01T18:43:44Z</dc:date>
    <item>
      <title>Aggregated Current Year vs. Previous Year with Date Range Slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregated-Current-Year-vs-Previous-Year-with-Date-Range-Slicer/m-p/750082#M2667</link>
      <description>&lt;P&gt;I'm creating a report using a matrix visual with Rows set to a product line hierarchy (division-&amp;gt;line-&amp;gt;item) and values including Invoiced Sales, Units, the previous year values for both, and the deltas between the two.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using a date slicer where the user is able to pick the date range. The idea is that in the same canvas, a user could look at YTD (1/1/2019 - 7/26/2019), MTD (7/1/2019 - 7/26/2019), or previous years (1/1/2018 - 7/26/2018).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Initially, I was using this bit of DAX to shift my max and min dates (set by the slicer) back one year each:&lt;/P&gt;&lt;PRE&gt;PY Sales = 
VAR CurrentDateMax = MAX(‘Sales Orders’[INVOICE DATE])
VAR CurrentDateMin = MIN(‘Sales Orders’[INVOICE DATE])
VAR EarliestDate = MIN(DateDim[Date])
VAR PYDateMax = IF(YEAR(CurrentDateMin) &amp;lt; YEAR(EarliestDate), EarliestDate,
                DATE(YEAR(CurrentDateMax)-1, MONTH(CurrentDateMax), DAY(CurrentDateMax))
)
VAR PYDateMin = IF(YEAR(CurrentDateMin) &amp;lt; YEAR(EarliestDate), EarliestDate,
                DATE(YEAR(CurrentDateMin)-1, MONTH(CurrentDateMin), DAY(CurrentDateMin))
)
RETURN
CALCULATE(
    SUM(‘Sales Orders’[Invoiced Sales $]),
    FILTER(
        ALL(‘Sales Orders’[INVOICE DATE]),
        ‘Sales Orders’[INVOICE DATE] &amp;gt;= PYDateMin &amp;amp;&amp;amp;
        ‘Sales Orders’[INVOICE DATE] &amp;lt;= PYDateMax
    )
)&lt;/PRE&gt;&lt;P&gt;Here's my issue:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this particular example, the product division level ($214k) is just wrong, overreporting by ~$7k. The product line level ($207k) is underreporting by a little over $125. In other examples, the grand total is correct, while individual product lines don't add up to the total.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This almost seems like an AutoExists issue &lt;A href="https://www.sqlbi.com/articles/understanding-dax-auto-exist/" target="_self"&gt;(refer to this excellent article from sqlbi)&lt;/A&gt;, but my Sales Order, Item, and Date tables are separate, so I didn't think this behavior should be invoked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm completely stumped as to why this is happening, and I'm not really sure how to move forward without completely redesigning my report. A lot of the functionality from the report comes from the user being able to arbitrarily decide on a date range and then see the delta from there. Any help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2019 13:35:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregated-Current-Year-vs-Previous-Year-with-Date-Range-Slicer/m-p/750082#M2667</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-26T13:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregated Current Year vs. Previous Year with Date Range Slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregated-Current-Year-vs-Previous-Year-with-Date-Range-Slicer/m-p/750121#M2671</link>
      <description>&lt;P&gt;Mate, be so kind, please, and share the pbix file. You can share it via Google Drive or OneDrive. Just don't forget to set the permissions right. OneDrive is preferable. Dropbox will do as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2019 14:05:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregated-Current-Year-vs-Previous-Year-with-Date-Range-Slicer/m-p/750121#M2671</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-26T14:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregated Current Year vs. Previous Year with Date Range Slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregated-Current-Year-vs-Previous-Year-with-Date-Range-Slicer/m-p/755539#M2976</link>
      <description>&lt;P&gt;IT granted me access to share via OneDrive:&lt;/P&gt;&lt;P&gt;&lt;A title="Sample PBIX" href="https://hagercompanies-my.sharepoint.com/:u:/g/personal/cisenberg_hagerco_com/EZrgNEQwkm5Dv9H2kPEmLXkBU3MbJAPjkj0HGlnxepT8sw?e=LJWhSu" target="_self"&gt;Sample PBIX&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That being said, I believe that I've figured out the problem and solution in the interim. Long story short, I actually used my DateDim table to filter the canvas instead of INVOICE_DATE, and I modified my measure to simply use SAMEPERIODLASTYEAR(); all of the preliminary validation I've done confirms that this approach works. This was infinitely easier than the approaches I've tried before, and it's a good example of why you want to appropriately model your data and then use the model properly!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The detailed explanation is that when I used INVOICE_DATE as a filter (and SALES_CCN), since these fields are both in the same table as my [Invoiced Sales $], my measure invoked DAX Autoexists via the CALCULATE() function. Effectively, this excluded sales of items in 2018 that were not sold in 2019, thus why we see no PY sales in the old method. Per the excellent article I referenced in my original post, there is no way to bypass Autoexist other than to filter a table using fields from other tables, and for that, you need a proper star schema.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate the help on this; creating the sample file got me thinking in the right direction.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 18:43:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregated-Current-Year-vs-Previous-Year-with-Date-Range-Slicer/m-p/755539#M2976</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-01T18:43:44Z</dc:date>
    </item>
  </channel>
</rss>

