<?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: Count rows in the period between dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-in-the-period-between-dates/m-p/3010095#M102026</link>
    <description>&lt;P&gt;Hi ,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="496410" data-lia-user-login="monicaalves4" class="lia-mention lia-mention-user"&gt;monicaalves4&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your description, you want to get the count of items which type = "Type1" and you want to make the calculation dynamic? Like last n days?&lt;/P&gt;
&lt;P&gt;Here are the steps you can refer to :&lt;BR /&gt;(1)We can create a what-if parameter as a slicer:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;(2)Then we can create a measure like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
var _slicer= [Parameter Value]
var _first_day = TODAY()- _slicer+1
var _t =  FILTER('Table', 'Table'[Type]="Type1" &amp;amp;&amp;amp; 'Table'[CreatedDate]&amp;gt;= _first_day &amp;amp;&amp;amp; 'Table'[CreatedDate]&amp;lt;=TODAY())
return
COUNTROWS(_t)&lt;/LI-CODE&gt;
&lt;P&gt;(3)Then we can meet your need , when we select the slicer n, it means we get the count of the items in the last n days:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Aniya Zhang&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt; it as the solution&lt;/EM&gt;&amp;nbsp;to help the other members find it more quickly&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jan 2023 01:44:50 GMT</pubDate>
    <dc:creator>v-yueyunzh-msft</dc:creator>
    <dc:date>2023-01-10T01:44:50Z</dc:date>
    <item>
      <title>Count rows in the period between dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-in-the-period-between-dates/m-p/3009652#M102005</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table similar to the table below and I would like to make a measure that calculates how many items there are with today's and yesterday's created date.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I started by using the following formula&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;COUNT&lt;/SPAN&gt;&lt;SPAN&gt;('&lt;/SPAN&gt;&lt;SPAN&gt;items'&lt;/SPAN&gt;&lt;SPAN&gt;[CreatedDate]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;'items'&lt;/SPAN&gt;&lt;SPAN&gt;[CreatedDate]&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;Today,&lt;/SPAN&gt;&lt;SPAN&gt;'items'&lt;/SPAN&gt;&lt;SPAN&gt;[Type]&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"Type 1"&lt;/SPAN&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This formula gives me a measure with total items of "Type 1" and created today. Now I would like that give me back the itens today and yesterday what do I need to change? what if i want the ones created in the last 3 days or during this week?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 09 Jan 2023 19:03:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-in-the-period-between-dates/m-p/3009652#M102005</guid>
      <dc:creator>monicaalves4</dc:creator>
      <dc:date>2023-01-09T19:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Count rows in the period between dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-in-the-period-between-dates/m-p/3009663#M102006</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;It is for creating a new measure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Items count from one day before to today: =
CALCULATE (
    COUNTROWS ( Data ),
    Data[Type] = "Type1",
    Data[CreatedDate]
        &amp;gt;= TODAY () - 1
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 19:13:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-in-the-period-between-dates/m-p/3009663#M102006</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2023-01-09T19:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Count rows in the period between dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-in-the-period-between-dates/m-p/3009958#M102018</link>
      <description>&lt;P&gt;hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="496410" data-lia-user-login="monicaalves4" class="lia-mention lia-mention-user"&gt;monicaalves4&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In addition to Jihwan's solution, you may also try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CountMeasure =&lt;/P&gt;&lt;P&gt;COUNTROWS(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; FILTER(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;items, items[CreateDate]&amp;gt;=TODAY()-1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;amp;&amp;amp;items[Type]="Type1"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;pls replace 1 with 2, to get the last 3 days count; 1 with 6, to get the last week count.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 23:53:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-in-the-period-between-dates/m-p/3009958#M102018</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-01-09T23:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Count rows in the period between dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-in-the-period-between-dates/m-p/3010095#M102026</link>
      <description>&lt;P&gt;Hi ,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="496410" data-lia-user-login="monicaalves4" class="lia-mention lia-mention-user"&gt;monicaalves4&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your description, you want to get the count of items which type = "Type1" and you want to make the calculation dynamic? Like last n days?&lt;/P&gt;
&lt;P&gt;Here are the steps you can refer to :&lt;BR /&gt;(1)We can create a what-if parameter as a slicer:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;(2)Then we can create a measure like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
var _slicer= [Parameter Value]
var _first_day = TODAY()- _slicer+1
var _t =  FILTER('Table', 'Table'[Type]="Type1" &amp;amp;&amp;amp; 'Table'[CreatedDate]&amp;gt;= _first_day &amp;amp;&amp;amp; 'Table'[CreatedDate]&amp;lt;=TODAY())
return
COUNTROWS(_t)&lt;/LI-CODE&gt;
&lt;P&gt;(3)Then we can meet your need , when we select the slicer n, it means we get the count of the items in the last n days:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Aniya Zhang&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt; it as the solution&lt;/EM&gt;&amp;nbsp;to help the other members find it more quickly&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 01:44:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-in-the-period-between-dates/m-p/3010095#M102026</guid>
      <dc:creator>v-yueyunzh-msft</dc:creator>
      <dc:date>2023-01-10T01:44:50Z</dc:date>
    </item>
  </channel>
</rss>

