<?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: Hospital Occupancy by Month in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hospital-Occupancy-by-Month/m-p/3654159#M141574</link>
    <description>&lt;P&gt;Calculate the hours of multi-month stay!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my head, I am going to connect the date table to the data on both arrival data and departure date, both as inactive relationships but as for the DAX measure, no idea where to go with this&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jan 2024 13:34:09 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-01-23T13:34:09Z</dc:date>
    <item>
      <title>Hospital Occupancy by Month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hospital-Occupancy-by-Month/m-p/3651710#M141468</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working with some hospital data and need to calculate the length of stay in hours. The issue I am having is that I need to calculate it for the month so if a stay starts in January and ends in March, I need to be able to calulate the total stay in hours for January only rather than the total stay in hours.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data looks like this;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date Table - standard date table from Enterprise DNA.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hospital Data - arrival date, departure date, total stay in hours, total stay in days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 13:19:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hospital-Occupancy-by-Month/m-p/3651710#M141468</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-22T13:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Hospital Occupancy by Month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hospital-Occupancy-by-Month/m-p/3652541#M141502</link>
      <description>&lt;P&gt;Do you want to attribute the entire stay in hours to the first month of the stay, or are you trying to calculate the hours for each month of a multi-month stay?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 21:52:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hospital-Occupancy-by-Month/m-p/3652541#M141502</guid>
      <dc:creator>AUaero</dc:creator>
      <dc:date>2024-01-22T21:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Hospital Occupancy by Month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hospital-Occupancy-by-Month/m-p/3654159#M141574</link>
      <description>&lt;P&gt;Calculate the hours of multi-month stay!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my head, I am going to connect the date table to the data on both arrival data and departure date, both as inactive relationships but as for the DAX measure, no idea where to go with this&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 13:34:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hospital-Occupancy-by-Month/m-p/3654159#M141574</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-23T13:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: Hospital Occupancy by Month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hospital-Occupancy-by-Month/m-p/3654560#M141586</link>
      <description>&lt;P&gt;Can you share a sanitized copy of your dataset or share a sample of the stay data?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 15:59:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hospital-Occupancy-by-Month/m-p/3654560#M141586</guid>
      <dc:creator>AUaero</dc:creator>
      <dc:date>2024-01-23T15:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: Hospital Occupancy by Month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hospital-Occupancy-by-Month/m-p/3655269#M141606</link>
      <description>&lt;P&gt;Hi Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;If I understand correctly, the issue is that you want to calculate the length of stay in hours for stays within a specific month. Please &lt;SPAN&gt;try the following method and check if they can solve your problem:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1.Create a new measure. Enter the following DAX formula.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;LengthOfStayInHoursForMonth = 
VAR CurrentMonthStart = STARTOFMONTH('Date Table'[Date])
VAR CurrentMonthEnd = ENDOFMONTH('Date Table'[Date])
RETURN
SUMX(
    'Hospital Data',
    VAR Arrival = MAX('Hospital Data'[arrival date])
    VAR Departure = MIN('Hospital Data'[departure date], CurrentMonthEnd)
    VAR OverlapStart = MAX(Arrival, CurrentMonthStart)
    VAR OverlapEnd = MIN(Departure, CurrentMonthEnd)
    VAR HoursInMonth = IF(
        OverlapStart &amp;lt;= OverlapEnd, 
        DATEDIFF(OverlapStart, OverlapEnd, HOUR),
        0
    )
    RETURN HoursInMonth
)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2.The measure will calculate the hours for the specific month.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;If the above ones can’t help you get it working, c&lt;SPAN&gt;ould you please provide &lt;/SPAN&gt;more raw data(exclude sensitive data) with Text format&amp;nbsp;&lt;SPAN&gt;to make a deep troubleshooting? &lt;/SPAN&gt;It would be helpful to find out the solution.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Looking forward to your reply.&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Wisdom Wu&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 01:11:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hospital-Occupancy-by-Month/m-p/3655269#M141606</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-24T01:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: Hospital Occupancy by Month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hospital-Occupancy-by-Month/m-p/3656882#M141675</link>
      <description>&lt;P&gt;Thank you, I'll give this a try!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 12:04:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Hospital-Occupancy-by-Month/m-p/3656882#M141675</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-24T12:04:17Z</dc:date>
    </item>
  </channel>
</rss>

