<?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: Have a fixed Date range based on selected current period lastdate in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Have-a-fixed-Date-range-based-on-selected-current-period/m-p/2579215#M73956</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Does that make sense? If so, kindly mark my answer as the solution to close the case please. Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Community Support Team _ Polly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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, 15 Jun 2022 06:01:16 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-06-15T06:01:16Z</dc:date>
    <item>
      <title>Have a fixed Date range based on selected current period lastdate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Have-a-fixed-Date-range-based-on-selected-current-period/m-p/2556607#M72602</link>
      <description>&lt;P&gt;Hi Guys,&lt;BR /&gt;&lt;BR /&gt;I need some help. I created a model based on this article by SQLBI&amp;nbsp;sqlbi.com/articles/filtering-and-comparing-different-time-periods-with-power-bi/.&lt;BR /&gt;&lt;BR /&gt;I would like to have a fixed previous date slider based on the selection of current period date slider for example in the article the selected current period is 8/1/2009 to 8/31/2009. In my case, I would like the previous period to be from the Last date of current Period (8/31/2009) to a start date within the same dateperiod as selected in the current (7/1/2009).&lt;BR /&gt;&lt;BR /&gt;Therefore, if selected current period is two months then previous should be 2 months from the last date in date slider.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here's a screenshot of the before&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;After&amp;nbsp;&lt;/P&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, 03 Jun 2022 02:25:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Have-a-fixed-Date-range-based-on-selected-current-period/m-p/2556607#M72602</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-06-03T02:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: Have a fixed Date range based on selected current period lastdate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Have-a-fixed-Date-range-based-on-selected-current-period/m-p/2557111#M72632</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; ,&lt;/P&gt;
&lt;P&gt;You can initialize like that&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can however create a measure&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Same Date range last period = &lt;BR /&gt;var _diff = datediff(MIN('Date'[date]),max('Date'[date]),DAY)&lt;BR /&gt;var _p_st_date = MINX('Date',DATEADD('Date'[date],-1*_diff,Day))-1&lt;BR /&gt;var _p_end_date = MAXX('Date',DATEADD('Date'[date],-1*_diff,Day))-1&lt;BR /&gt;Return&lt;BR /&gt;CALCULATE(sum(Sales[Sales Amount]),all('Date'[date]),'Date'[date]&amp;gt;=_p_st_date &amp;amp;&amp;amp; 'Date'[date]&amp;lt;= _p_end_date&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Same Date range last period = &lt;BR /&gt;var _diff = datediff(MIN('Date'[date]),max('Date'[date]),DAY)&lt;BR /&gt;var _p_st_date = MINX('Date',DATEADD('Date'[date],-1*_diff,Day))-1&lt;BR /&gt;var _p_end_date = MAXX('Date',DATEADD('Date'[date],-1*_diff,Day))-1&lt;BR /&gt;Return&lt;BR /&gt;CALCULATE(sum(Sales[Sales Amount]),dateadd('Date'[date],-1*_diff,Day)&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 07:38:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Have-a-fixed-Date-range-based-on-selected-current-period/m-p/2557111#M72632</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-06-03T07:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Have a fixed Date range based on selected current period lastdate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Have-a-fixed-Date-range-based-on-selected-current-period/m-p/2559582#M72774</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for your solution.&lt;BR /&gt;&lt;BR /&gt;Is there a way the above measure can be used as a calculated column in the date table and also for it to be stand alone from the sales amount? Ideally, the previous period is to be used as a slicer with the current period to filter values for Sales Amount and Previous sales.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jun 2022 14:12:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Have-a-fixed-Date-range-based-on-selected-current-period/m-p/2559582#M72774</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-06-05T14:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Have a fixed Date range based on selected current period lastdate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Have-a-fixed-Date-range-based-on-selected-current-period/m-p/2562609#M72942</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please create relationship between the data table and&amp;nbsp;&lt;SPAN&gt;Sales table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Then create a column.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Same Date range last period =
VAR _diff =
    DATEDIFF ( MIN ( 'Date'[date] ), MAX ( 'Date'[date] ), DAY )
VAR _p_st_date =
    MINX ( 'Date', DATEADD ( 'Date'[date], -1 * _diff, DAY ) ) - 1
VAR _p_end_date =
    MAXX ( 'Date', DATEADD ( 'Date'[date], -1 * _diff, DAY ) ) - 1
RETURN
    CALCULATE (
        SUM ( Sales[Sales Amount] ),
        FILTER (
            'Date'[date],
            'Date'[date] &amp;gt;= _p_st_date
                &amp;amp;&amp;amp; 'Date'[date] &amp;lt;= _p_end_date
        )
    )
&lt;/LI-CODE&gt;
&lt;P&gt;Or&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Same Date range last period =
VAR _diff =
    DATEDIFF ( MIN ( 'Date'[date] ), MAX ( 'Date'[date] ), DAY )
VAR _p_st_date =
    MINX ( 'Date', DATEADD ( 'Date'[date], -1 * _diff, DAY ) ) - 1
VAR _p_end_date =
    MAXX ( 'Date', DATEADD ( 'Date'[date], -1 * _diff, DAY ) ) - 1
RETURN
    CALCULATE (
        SUM ( Sales[Sales Amount] ),
        DATEADD ( 'Date'[date], -1 * _diff, DAY )
    )
&lt;/LI-CODE&gt;
&lt;P&gt;If I have misunderstood your meaning, please provide you pbix file without privacy information and desired output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;How to Get Your Question Answered Quickly&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Community Support Team _ Polly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 03:17:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Have-a-fixed-Date-range-based-on-selected-current-period/m-p/2562609#M72942</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-06-07T03:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Have a fixed Date range based on selected current period lastdate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Have-a-fixed-Date-range-based-on-selected-current-period/m-p/2579215#M73956</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Does that make sense? If so, kindly mark my answer as the solution to close the case please. Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Community Support Team _ Polly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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, 15 Jun 2022 06:01:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Have-a-fixed-Date-range-based-on-selected-current-period/m-p/2579215#M73956</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-06-15T06:01:16Z</dc:date>
    </item>
  </channel>
</rss>

