<?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: Power BI Calendar with Specific Days of Week and Hours to Count in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-Calendar-with-Specific-Days-of-Week-and-Hours-to-Count/m-p/3485149#M133348</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Base on your description, it seems that you want to get the hours which exclude the weekends. And the normal working time is from 8:00 AM to 5:00 PM. You can refer the following thread to get it:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Desktop/Calculating-working-hours-between-2-dates-disregarding-weekends/m-p/907433#M434894" target="_blank"&gt;Solved: Re: Calculating working hours between 2 dates disr... - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Working Hours =
VAR StartDate = 'YourTable'[Start Date/Time]
VAR EndDate = 'YourTable'[End Date/Time]
VAR BusinessHoursStart =
    TIME ( 8, 0, 0 )
VAR BusinessHoursEnd =
    TIME ( 17, 0, 0 )
VAR BusinessDays =
    COUNTROWS (
        FILTER (
            'YourCalendarTable',
            'YourCalendarTable'[Date] &amp;gt;= StartDate
                &amp;amp;&amp;amp; 'YourCalendarTable'[Date] &amp;lt;= EndDate
                &amp;amp;&amp;amp; WEEKDAY ( 'YourCalendarTable'[Date], 2 ) &amp;lt; 6
                &amp;amp;&amp;amp; NOT ( 'YourCalendarTable'[Date] IN VALUES ( 'YourHolidaysTable'[Date] ) )
        )
    )
VAR StartHour =
    IF (
        WEEKDAY ( StartDate, 2 ) &amp;lt; 6,
        MAX (
            BusinessHoursStart,
            TIME ( HOUR ( StartDate ), MINUTE ( StartDate ), SECOND ( StartDate ) )
        ),
        BusinessHoursStart
    )
VAR EndHour =
    IF (
        WEEKDAY ( EndDate, 2 ) &amp;lt; 6,
        MIN (
            BusinessHoursEnd,
            TIME ( HOUR ( EndDate ), MINUTE ( EndDate ), SECOND ( EndDate ) )
        ),
        BusinessHoursEnd
    )
RETURN
    IF (
        BusinessDays &amp;gt; 0,
        ( BusinessDays - 1 ) * ( BusinessHoursEnd - BusinessHoursStart ) + ( EndHour - StartHour ),
        0
    )&lt;/LI-CODE&gt;
&lt;P&gt;If the above one can't help you get the expected result, please&amp;nbsp;&lt;SPAN&gt;provide some&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;raw data&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;in the table&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;exclude&amp;nbsp;sensitive&amp;nbsp;data&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt;) with&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;&lt;SPAN&gt;format&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;and your&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;expected result&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;with backend logic and special examples.&amp;nbsp; It would be helpful to find out the solution. You can refer the following links to share the required info:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-provide-sample-data-in-the-Power-BI-Forum%2Fba-p%2F963216&amp;amp;data=05%7C01%7CClaire.Dong%40microsoft.com%7Cada9149bd91546a8432508dacd31ef9b%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047911607737134%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=EJlYfclgtrjgAEYj9Uo1AauqxaQm3hlQsjJMo4zCY1M%3D&amp;amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer"&gt;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;if you can share a&amp;nbsp;&lt;FONT color="#008000"&gt;&lt;STRONG&gt;simplified&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;pbix file. You can refer the following link to upload the file to the community. Thank you.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FDesktop%2FHow-to-upload-PBI-in-Community%2Fm-p%2F1672886&amp;amp;data=04%7C01%7Cv-yiruan%40microsoft.com%7C4f580813734d4a8355b008da16f6e91a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637847547341062885%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;amp;sdata=YJvujige2YITXKbKED9JieQm5LBdf%2F3IYPM4ggdiijQ%3D&amp;amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer"&gt;How to upload PBI in Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
    <pubDate>Thu, 19 Oct 2023 09:06:57 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-10-19T09:06:57Z</dc:date>
    <item>
      <title>Power BI Calendar with Specific Days of Week and Hours to Count</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-Calendar-with-Specific-Days-of-Week-and-Hours-to-Count/m-p/3456488#M131762</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using PowerBI for an analysis and I am a bit stuck on how to do one specific calculation. I have the times that an shift of employees (for simplicity) started working and the time they stopped. In this example they can work for multiple days at a time. So one row will have the information about that shift as well as their start date/time (say 10/1/2023 at 11am) to their stop date/time (say 10/3/2023 at 12pm).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to do an analysis to count how many hours each shift worked that were specifically weekends (Saturdays and Sundays) from 8am-5pm. The purpose of this is to calculate the hours paid that could have been avoidable overtime if it was not a weekend. I know how to create a calendar and how to flag specific days as weekends, but not sure how to include the time element or how to do a count to see how many hours each employee shift worked that was avoidable overtime.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone help to point me in the right direction or idea? Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2023 18:40:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-Calendar-with-Specific-Days-of-Week-and-Hours-to-Count/m-p/3456488#M131762</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-02T18:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI Calendar with Specific Days of Week and Hours to Count</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-Calendar-with-Specific-Days-of-Week-and-Hours-to-Count/m-p/3456560#M131765</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;See if this approach gets you there:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Hour-Breakdown/m-p/625085#M306" target="_blank"&gt;Hour Breakdown - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2023 19:27:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-Calendar-with-Specific-Days-of-Week-and-Hours-to-Count/m-p/3456560#M131765</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2023-10-02T19:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI Calendar with Specific Days of Week and Hours to Count</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-Calendar-with-Specific-Days-of-Week-and-Hours-to-Count/m-p/3485149#M133348</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Base on your description, it seems that you want to get the hours which exclude the weekends. And the normal working time is from 8:00 AM to 5:00 PM. You can refer the following thread to get it:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Desktop/Calculating-working-hours-between-2-dates-disregarding-weekends/m-p/907433#M434894" target="_blank"&gt;Solved: Re: Calculating working hours between 2 dates disr... - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Working Hours =
VAR StartDate = 'YourTable'[Start Date/Time]
VAR EndDate = 'YourTable'[End Date/Time]
VAR BusinessHoursStart =
    TIME ( 8, 0, 0 )
VAR BusinessHoursEnd =
    TIME ( 17, 0, 0 )
VAR BusinessDays =
    COUNTROWS (
        FILTER (
            'YourCalendarTable',
            'YourCalendarTable'[Date] &amp;gt;= StartDate
                &amp;amp;&amp;amp; 'YourCalendarTable'[Date] &amp;lt;= EndDate
                &amp;amp;&amp;amp; WEEKDAY ( 'YourCalendarTable'[Date], 2 ) &amp;lt; 6
                &amp;amp;&amp;amp; NOT ( 'YourCalendarTable'[Date] IN VALUES ( 'YourHolidaysTable'[Date] ) )
        )
    )
VAR StartHour =
    IF (
        WEEKDAY ( StartDate, 2 ) &amp;lt; 6,
        MAX (
            BusinessHoursStart,
            TIME ( HOUR ( StartDate ), MINUTE ( StartDate ), SECOND ( StartDate ) )
        ),
        BusinessHoursStart
    )
VAR EndHour =
    IF (
        WEEKDAY ( EndDate, 2 ) &amp;lt; 6,
        MIN (
            BusinessHoursEnd,
            TIME ( HOUR ( EndDate ), MINUTE ( EndDate ), SECOND ( EndDate ) )
        ),
        BusinessHoursEnd
    )
RETURN
    IF (
        BusinessDays &amp;gt; 0,
        ( BusinessDays - 1 ) * ( BusinessHoursEnd - BusinessHoursStart ) + ( EndHour - StartHour ),
        0
    )&lt;/LI-CODE&gt;
&lt;P&gt;If the above one can't help you get the expected result, please&amp;nbsp;&lt;SPAN&gt;provide some&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;raw data&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;in the table&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;exclude&amp;nbsp;sensitive&amp;nbsp;data&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt;) with&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;&lt;SPAN&gt;format&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;and your&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;expected result&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;with backend logic and special examples.&amp;nbsp; It would be helpful to find out the solution. You can refer the following links to share the required info:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-provide-sample-data-in-the-Power-BI-Forum%2Fba-p%2F963216&amp;amp;data=05%7C01%7CClaire.Dong%40microsoft.com%7Cada9149bd91546a8432508dacd31ef9b%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047911607737134%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=EJlYfclgtrjgAEYj9Uo1AauqxaQm3hlQsjJMo4zCY1M%3D&amp;amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer"&gt;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;if you can share a&amp;nbsp;&lt;FONT color="#008000"&gt;&lt;STRONG&gt;simplified&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;pbix file. You can refer the following link to upload the file to the community. Thank you.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FDesktop%2FHow-to-upload-PBI-in-Community%2Fm-p%2F1672886&amp;amp;data=04%7C01%7Cv-yiruan%40microsoft.com%7C4f580813734d4a8355b008da16f6e91a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637847547341062885%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;amp;sdata=YJvujige2YITXKbKED9JieQm5LBdf%2F3IYPM4ggdiijQ%3D&amp;amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer"&gt;How to upload PBI in Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 09:06:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-Calendar-with-Specific-Days-of-Week-and-Hours-to-Count/m-p/3485149#M133348</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-19T09:06:57Z</dc:date>
    </item>
  </channel>
</rss>

