<?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 Problem with DATESINPERIOD function in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DATESINPERIOD-function/m-p/1328640#M23482</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table of self reports of COVID symptoms which contatins user ID (AccountName) and the date of the report.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a function which sums the unique reports over the last two weeks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I enter the dates manually using DATESBETWEEN I get the expected result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Reports_Lst2Wks_ALT = CALCULATE(DISTINCTCOUNT(selfreports[AccountName]),DATESBETWEEN(selfreports[Date],DATE(2020,08,14),DATE(2020,08,27)))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;However I need the function to be adaptive to the current date.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I would expect the following function to give the same result as above:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Reports_Lst2Wks = CALCULATE(DISTINCTCOUNT(selfreports[AccountName]),DATESINPERIOD(selfreports[Date],[TODAY](),-7,DAY))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;But instead it gives a result of 0.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Can anyone see what the problem might be?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 27 Aug 2020 10:55:42 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-08-27T10:55:42Z</dc:date>
    <item>
      <title>Problem with DATESINPERIOD function</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DATESINPERIOD-function/m-p/1328640#M23482</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table of self reports of COVID symptoms which contatins user ID (AccountName) and the date of the report.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a function which sums the unique reports over the last two weeks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I enter the dates manually using DATESBETWEEN I get the expected result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Reports_Lst2Wks_ALT = CALCULATE(DISTINCTCOUNT(selfreports[AccountName]),DATESBETWEEN(selfreports[Date],DATE(2020,08,14),DATE(2020,08,27)))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;However I need the function to be adaptive to the current date.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I would expect the following function to give the same result as above:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Reports_Lst2Wks = CALCULATE(DISTINCTCOUNT(selfreports[AccountName]),DATESINPERIOD(selfreports[Date],[TODAY](),-7,DAY))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;But instead it gives a result of 0.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Can anyone see what the problem might be?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 27 Aug 2020 10:55:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DATESINPERIOD-function/m-p/1328640#M23482</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-27T10:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with DATESINPERIOD function</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DATESINPERIOD-function/m-p/1328671#M23484</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;- See if this helps you better understand DATESINPERIOD -&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/To-bleep-With-DATEADD/m-p/1259467#M583" target="_blank"&gt;https://community.powerbi.com/t5/Quick-Measures-Gallery/To-bleep-With-DATEADD/m-p/1259467#M583&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 11:05:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DATESINPERIOD-function/m-p/1328671#M23484</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-08-27T11:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with DATESINPERIOD function</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DATESINPERIOD-function/m-p/1328680#M23485</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , not very clear , refer if this can help&lt;/P&gt;
&lt;P&gt;&lt;A href="https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3" target="_blank"&gt;https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or measures like, with date calendar&lt;/P&gt;
&lt;P&gt;Rolling 14day = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX(Sales[Sales Date]),-14,Day)) &lt;/P&gt;
&lt;P&gt;Rolling 14day = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-14,Day))&lt;/P&gt;
&lt;P&gt;Rolling 14day = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],Today(),-14,Day))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer : &lt;BR /&gt;&lt;A href="https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions" target="_blank"&gt;https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions&lt;/A&gt; &lt;BR /&gt;&lt;A href="https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi" target="_blank"&gt;https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/" target="_blank"&gt;https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;See if my webinar on Time Intelligence can help: &lt;A href="https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184" target="_blank"&gt;https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Appreciate your Kudos.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 11:06:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DATESINPERIOD-function/m-p/1328680#M23485</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-08-27T11:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with DATESINPERIOD function</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DATESINPERIOD-function/m-p/1328724#M23489</link>
      <description>&lt;P&gt;Hey&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you can use this DAX statement instead:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Reports_Lst2Wks_ALT = 
var _today = TODAY()
var _7DaysBeforeToday = _today -7
return
CALCULATE(
DISTINCTCOUNT(selfreports[AccountName])
,DATESBETWEEN(selfreports[Date] , _7DaysBeforeToday , _today)
)&lt;/LI-CODE&gt;
&lt;P&gt;DATESINPERIOD requires a dedicated date table without gaps, for this I recommend following the link&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;provided in his post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully, this helps to tackle your challenge.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 11:14:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DATESINPERIOD-function/m-p/1328724#M23489</guid>
      <dc:creator>TomMartens</dc:creator>
      <dc:date>2020-08-27T11:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with DATESINPERIOD function</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DATESINPERIOD-function/m-p/1328841#M23498</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;Are you not slicing data by dates table?&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;=
VAR MaxVisibleDate =
    MAX ( Dates[Date] )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( selfreports[AccountName] ),
        DATESINPERIOD ( Dates[Date], MaxVisibleDate, -7, DAY )
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 12:06:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DATESINPERIOD-function/m-p/1328841#M23498</guid>
      <dc:creator>AntrikshSharma</dc:creator>
      <dc:date>2020-08-27T12:06:48Z</dc:date>
    </item>
  </channel>
</rss>

