<?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: Counting rows/incidences between date columns in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-rows-incidences-between-date-columns/m-p/3649608#M141362</link>
    <description>&lt;P&gt;Click here to download solution&lt;/P&gt;&lt;P&gt;&lt;A href="https://1drv.ms/u/s!AgMTUY3Uvq3bg8t83mZftvYv6yxOYA?e=NTlqsv" target="_self"&gt;Download PBIX from Onedrive&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How it works&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create relationships&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create dax measure ...&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ValidCount = 
VAR mindate = MIN('Calendar'[Date])
VAR maxdate = MAX('Calendar'[Date])
VAR mysubset = FILTER(Facts,Facts[Start_Date] &amp;lt;= maxdate &amp;amp;&amp;amp; Facts[End_Date] &amp;lt;= mindate)
RETURN
CALCULATE(
DISTINCTCOUNT(Facts[ID]),
mysubset
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create report ...&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the clear description of the problem with example data. I wish everyone did that!&lt;/P&gt;&lt;P&gt;Remember we are unpaid volunteers, and you have got free expert help which took a lot of effort,&lt;BR /&gt;This solution works and does exactly what you asked.&lt;BR /&gt;So please quickly click the [accept as solution] and the thumbs up button to leave kudos.&amp;nbsp;&lt;/P&gt;&lt;P&gt;One question per ticket please. If you need to change or extend your request then please raise a new ticket.&lt;/P&gt;&lt;P&gt;You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you !&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you quote &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="177566" data-lia-user-login="speedramps" class="lia-mention lia-mention-user"&gt;speedramps&lt;/a&gt; in your next tickets then I will then receive an automatic notification, and will be delighted to help you again.&lt;/P&gt;&lt;P&gt;Please now click the [accept as solution] and the thumbs up button.&amp;nbsp; Thank you.&lt;/P&gt;</description>
    <pubDate>Sat, 20 Jan 2024 14:50:35 GMT</pubDate>
    <dc:creator>speedramps</dc:creator>
    <dc:date>2024-01-20T14:50:35Z</dc:date>
    <item>
      <title>Counting rows/incidences between date columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-rows-incidences-between-date-columns/m-p/3648595#M141313</link>
      <description>&lt;P&gt;I have a table of the form:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Status&lt;/TD&gt;&lt;TD&gt;Start_Date&lt;/TD&gt;&lt;TD&gt;End_Date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0001&lt;/TD&gt;&lt;TD&gt;Registered&lt;/TD&gt;&lt;TD&gt;01/01/2024&lt;/TD&gt;&lt;TD&gt;02/01/2024&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0001&lt;/TD&gt;&lt;TD&gt;In-Progress&lt;/TD&gt;&lt;TD&gt;02/01/2024&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;05/01/2024&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0002&lt;/TD&gt;&lt;TD&gt;Registered&lt;/TD&gt;&lt;TD&gt;02/01/2024&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;04/01/2024&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0001&lt;/TD&gt;&lt;TD&gt;Success&lt;/TD&gt;&lt;TD&gt;05/01/2024&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;20/01/2024&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0002&lt;/TD&gt;&lt;TD&gt;In-Progress&lt;/TD&gt;&lt;TD&gt;05/01/2024&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;05/01/2024&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0002&lt;/TD&gt;&lt;TD&gt;Failure&lt;/TD&gt;&lt;TD&gt;05/01/2024&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;20/01/2024&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to plot count vs date, where for each date, we count the number IDs on that date split by status (Registered vs In-Progress vs Success vs Failure). The user would choose to filter when to start counting&amp;nbsp;&lt;EM&gt;from&amp;nbsp;&lt;/EM&gt;(ex: only count IDs in the last 7 days, 6 months, one year) &lt;STRONG&gt;through a slicer on the side&lt;/STRONG&gt;. Call this &lt;STRONG&gt;user_start_date&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Caveat&lt;/STRONG&gt;: The formula for the first two (registered and in-progress) is different for the formulas for the last two (success and failure)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Registered_Count = COUNT(Status == "Registered" &amp;amp; start_date &amp;lt;= date &amp;lt; end_date)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;but&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Success_Count = COUNT(Status == "Registered" &amp;amp; user_start_date &amp;lt;= start_date &amp;lt;= date &amp;lt; end_date)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is done so that - if the user only wishes to see IDs in the last 7 days, we do not view IDs that have already been successful (or failed) before the 7 days (on the other hand we still wish to see those that are still Registered/In-Progress).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In-Progress_Count has the same formula as Registered_Count (but Status == Registered) and Failure_Count has the same formula as Success_Count (but Status == Failure).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think the first two should be easier (although I am new to DAX so still don't know how to implement it), but the latter two are based on user filtering. I think given the user's slicer selection, you would want to filter the table so that start_date &amp;gt;= user_start date first and then apply the formula. But I don't know how to do this. Help would be appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have set up an active relationship between an AUTOCALENDAR() table and the start_date, and an inactive relationship between the calendar and the end date. But not sure how to leverage this!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2024 16:00:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-rows-incidences-between-date-columns/m-p/3648595#M141313</guid>
      <dc:creator>DateSurfer</dc:creator>
      <dc:date>2024-01-19T16:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Counting rows/incidences between date columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-rows-incidences-between-date-columns/m-p/3649608#M141362</link>
      <description>&lt;P&gt;Click here to download solution&lt;/P&gt;&lt;P&gt;&lt;A href="https://1drv.ms/u/s!AgMTUY3Uvq3bg8t83mZftvYv6yxOYA?e=NTlqsv" target="_self"&gt;Download PBIX from Onedrive&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How it works&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create relationships&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create dax measure ...&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ValidCount = 
VAR mindate = MIN('Calendar'[Date])
VAR maxdate = MAX('Calendar'[Date])
VAR mysubset = FILTER(Facts,Facts[Start_Date] &amp;lt;= maxdate &amp;amp;&amp;amp; Facts[End_Date] &amp;lt;= mindate)
RETURN
CALCULATE(
DISTINCTCOUNT(Facts[ID]),
mysubset
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create report ...&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the clear description of the problem with example data. I wish everyone did that!&lt;/P&gt;&lt;P&gt;Remember we are unpaid volunteers, and you have got free expert help which took a lot of effort,&lt;BR /&gt;This solution works and does exactly what you asked.&lt;BR /&gt;So please quickly click the [accept as solution] and the thumbs up button to leave kudos.&amp;nbsp;&lt;/P&gt;&lt;P&gt;One question per ticket please. If you need to change or extend your request then please raise a new ticket.&lt;/P&gt;&lt;P&gt;You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you !&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you quote &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="177566" data-lia-user-login="speedramps" class="lia-mention lia-mention-user"&gt;speedramps&lt;/a&gt; in your next tickets then I will then receive an automatic notification, and will be delighted to help you again.&lt;/P&gt;&lt;P&gt;Please now click the [accept as solution] and the thumbs up button.&amp;nbsp; Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jan 2024 14:50:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-rows-incidences-between-date-columns/m-p/3649608#M141362</guid>
      <dc:creator>speedramps</dc:creator>
      <dc:date>2024-01-20T14:50:35Z</dc:date>
    </item>
  </channel>
</rss>

