<?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: Calculate measure between relative dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-measure-between-relative-dates/m-p/1863430#M39938</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You cannot use time-intel functions with any table you want. This does not work like that. Please read carefully the documentation on &lt;A href="http://dax.guide/datesinperiod" target="_blank" rel="noopener"&gt;DATESINPERIOD&lt;/A&gt;. The whole of it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, please go to &lt;A href="https://docs.microsoft.com/en-us/power-bi/guidance/star-schema" target="_self"&gt;this place&lt;/A&gt; and read it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, once you know that you have to have a proper calendar in your model, you can write this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// Please bear in mind that this code
// will not work correctly if you use
// the time-intel function on a non-calendar
// table.

Trend =
var LastVisibleDate = MAX( 'Calendar'[Date] )
var _3MonthPeriod =
    DATESINPERIOD(
        'Calendar'[Date],
        LastVisibleDate,
        -3,
        MONTH
    )
var Between6and3MonthPeriod =
    EXCEPT(
        DATESINPERIOD(
            'Calendar'[Date],
            LastVisibleDate,
            -6,
            MONTH
        ),
        _3MonthPeriod
    )
VAR three =
    CALCULATE(
        [Sales] / 3,
        _3MonthPeriod
    )
VAR six =
    CALCULATE(
        [Sales] / 3,
        Between6and3MonthPeriod
    )
RETURN
    DIVIDE(
        three,
        six
    )&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 25 May 2021 22:15:46 GMT</pubDate>
    <dc:creator>daxer-almighty</dc:creator>
    <dc:date>2021-05-25T22:15:46Z</dc:date>
    <item>
      <title>Calculate measure between relative dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-measure-between-relative-dates/m-p/1863178#M39929</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Looking to write measure that compares the avg sales from the past 3 months to the avg sales from the previous 3 months. This first piece is easy, but i'm struggling with calculating &lt;EM&gt;between&lt;/EM&gt; 3 months ago and 6 months ago. Is there an easy why to do this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Heres my current Dax, which works great. Problem is its taking the last 3 months avg and dividing by the last 6 months avg. Again, I need to somehow get it to only look at the 3-6 months ago range.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Trend = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var three = CALCULATE([Sales],DATESINPERIOD(Orders[date],LASTDATE(Orders[date]),-3,MONTH))/3&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var six = CALCULATE([Sales],DATESINPERIOD(Orders[date],LASTDATE(Orders[date]),-6,MONTH))/3&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;divide(three,six)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 25 May 2021 17:53:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-measure-between-relative-dates/m-p/1863178#M39929</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-05-25T17:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate measure between relative dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-measure-between-relative-dates/m-p/1863430#M39938</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You cannot use time-intel functions with any table you want. This does not work like that. Please read carefully the documentation on &lt;A href="http://dax.guide/datesinperiod" target="_blank" rel="noopener"&gt;DATESINPERIOD&lt;/A&gt;. The whole of it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, please go to &lt;A href="https://docs.microsoft.com/en-us/power-bi/guidance/star-schema" target="_self"&gt;this place&lt;/A&gt; and read it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, once you know that you have to have a proper calendar in your model, you can write this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// Please bear in mind that this code
// will not work correctly if you use
// the time-intel function on a non-calendar
// table.

Trend =
var LastVisibleDate = MAX( 'Calendar'[Date] )
var _3MonthPeriod =
    DATESINPERIOD(
        'Calendar'[Date],
        LastVisibleDate,
        -3,
        MONTH
    )
var Between6and3MonthPeriod =
    EXCEPT(
        DATESINPERIOD(
            'Calendar'[Date],
            LastVisibleDate,
            -6,
            MONTH
        ),
        _3MonthPeriod
    )
VAR three =
    CALCULATE(
        [Sales] / 3,
        _3MonthPeriod
    )
VAR six =
    CALCULATE(
        [Sales] / 3,
        Between6and3MonthPeriod
    )
RETURN
    DIVIDE(
        three,
        six
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 25 May 2021 22:15:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-measure-between-relative-dates/m-p/1863430#M39938</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-05-25T22:15:46Z</dc:date>
    </item>
  </channel>
</rss>

