<?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: Function to collect leftover hours if exceeding 8 hours of work? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-to-collect-leftover-hours-if-exceeding-8-hours-of-work/m-p/4374116#M173677</link>
    <description>&lt;P&gt;Thanks for the help! The table I provided the example was already grouped to specific columns I needed. So I'm glad I'm getting closer to the results I'm needing.&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jan 2025 17:15:04 GMT</pubDate>
    <dc:creator>Tummi</dc:creator>
    <dc:date>2025-01-21T17:15:04Z</dc:date>
    <item>
      <title>Function to collect leftover hours if exceeding 8 hours of work?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-to-collect-leftover-hours-if-exceeding-8-hours-of-work/m-p/4372658#M173597</link>
      <description>&lt;P&gt;I'm trying to configure a formula to calculate the 'Overage' Hours of a days work. From my data I did a 'GroupBy' within PowerQuery to condense all my columns to only the necessary fields to narrow down my calculation for easier functionality.&lt;/P&gt;&lt;P&gt;However, I'm stuck on this final piece on this calculation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The goal is to be able to track how much time is worked past 8 hours (if you work 9 hours in 1 day, your overage hours would be 1 hour). In addition, a regular work week being 40 hours, I can exceed 40 hours and go into overtime within the same work day. I don't know how to manage this formula to sum 'Regular' hours and 'Overtime' hours together and subtract it from 8 to get the leftover hours worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My current formula is super simple as I keep trying to build on it, but don't know how to go about it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;=IF(SUM[Hours]-8&amp;lt;=0,"",SUM[Hours]-8)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date Category Person Hours&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;01/20/2025&lt;/TD&gt;&lt;TD&gt;Regular&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;5.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01/20/2025&lt;/TD&gt;&lt;TD&gt;Overtime&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;3.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01/20/2025&lt;/TD&gt;&lt;TD&gt;Regular&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01/20/2025&lt;/TD&gt;&lt;TD&gt;Regular&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Person A 1/20/2025 = 1 Overage hour (but 3.5 hours of Overtime)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Person B 1/20/2025 = 1 Overage hour (No overtime accumulated yet)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is over thousands of rows of variances of hours worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies if it doesn't make much sense I can try to clarify more if asked. But I'm still fairly a novice at DAX and Power Query but would love some insight and advice on how to get this solved.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 02:29:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-to-collect-leftover-hours-if-exceeding-8-hours-of-work/m-p/4372658#M173597</guid>
      <dc:creator>Tummi</dc:creator>
      <dc:date>2025-01-21T02:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: Function to collect leftover hours if exceeding 8 hours of work?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-to-collect-leftover-hours-if-exceeding-8-hours-of-work/m-p/4372987#M173612</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="430609" data-lia-user-login="Tummi" class="lia-mention lia-mention-user"&gt;Tummi&lt;/a&gt;&amp;nbsp;To calculate the 'Overage' hours for each person on each day, you can use Power Query to transform your data and then apply a custom formula. Here's a step-by-step approach to achieve this:&lt;/P&gt;
&lt;P&gt;Group By Date and Person:&lt;/P&gt;
&lt;P&gt;Go to the Home tab.&lt;BR /&gt;Click on Group By.&lt;BR /&gt;Group by Date and Person.&lt;BR /&gt;Add a new column for the sum of Hours.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Go to the Add Column tab.&lt;BR /&gt;Click on Custom Column.&lt;BR /&gt;Use the following formula to calculate the overage hours:&lt;/P&gt;
&lt;P&gt;if [Sum of Hours] &amp;gt; 8 then [Sum of Hours] - 8 else 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a more detailed example of the steps in Power Query:&lt;/P&gt;
&lt;P&gt;let&lt;BR /&gt;Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],&lt;BR /&gt;GroupedRows = Table.Group(Source, {"Date", "Person"}, {{"Total Hours", each List.Sum([Hours]), type number}}),&lt;BR /&gt;AddedCustom = Table.AddColumn(GroupedRows, "Overage Hours", each if [Total Hours] &amp;gt; 8 then [Total Hours] - 8 else 0),&lt;BR /&gt;RenamedColumns = Table.RenameColumns(AddedCustom,{{"Total Hours", "Sum of Hours"}})&lt;BR /&gt;in&lt;BR /&gt;RenamedColumns&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 06:39:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-to-collect-leftover-hours-if-exceeding-8-hours-of-work/m-p/4372987#M173612</guid>
      <dc:creator>bhanu_gautam</dc:creator>
      <dc:date>2025-01-21T06:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: Function to collect leftover hours if exceeding 8 hours of work?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-to-collect-leftover-hours-if-exceeding-8-hours-of-work/m-p/4373524#M173638</link>
      <description>&lt;P&gt;You could create a measure like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Overage hours =
SUMX (
    VALUES ( 'Date'[Date] ),
    VAR TotalHours =
        CALCULATE ( SUM ( 'Table'[Hours] ), REMOVEFILTERS ( 'Table'[Category] ) )
    VAR Result =
        IF ( TotalHours &amp;gt; 8, TotalHours - 8 )
    RETURN
        Result
)
&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 21 Jan 2025 11:25:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-to-collect-leftover-hours-if-exceeding-8-hours-of-work/m-p/4373524#M173638</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2025-01-21T11:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Function to collect leftover hours if exceeding 8 hours of work?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-to-collect-leftover-hours-if-exceeding-8-hours-of-work/m-p/4374114#M173676</link>
      <description>&lt;P&gt;I should have also mentioned that within the category there are other categories aside from 'Regular' and 'Overtime'. I looked into KEEPFILTERS and FILTER but haven't been able to mimic your code to output data towards it. I do think this is a step in the right direction. Any suggestions?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 17:14:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-to-collect-leftover-hours-if-exceeding-8-hours-of-work/m-p/4374114#M173676</guid>
      <dc:creator>Tummi</dc:creator>
      <dc:date>2025-01-21T17:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: Function to collect leftover hours if exceeding 8 hours of work?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-to-collect-leftover-hours-if-exceeding-8-hours-of-work/m-p/4374116#M173677</link>
      <description>&lt;P&gt;Thanks for the help! The table I provided the example was already grouped to specific columns I needed. So I'm glad I'm getting closer to the results I'm needing.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 17:15:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-to-collect-leftover-hours-if-exceeding-8-hours-of-work/m-p/4374116#M173677</guid>
      <dc:creator>Tummi</dc:creator>
      <dc:date>2025-01-21T17:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: Function to collect leftover hours if exceeding 8 hours of work?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-to-collect-leftover-hours-if-exceeding-8-hours-of-work/m-p/4375327#M173711</link>
      <description>&lt;P&gt;If you only want to count the regular and overtime categories you could use&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Overage hours =
SUMX (
    VALUES ( 'Date'[Date] ),
    VAR TotalHours =
        CALCULATE (
            SUM ( 'Table'[Hours] ),
            'Table'[Category] IN { "Regular", "Overtime" }
        )
    VAR Result =
        IF ( TotalHours &amp;gt; 8, TotalHours - 8 )
    RETURN
        Result
)
&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 22 Jan 2025 09:26:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-to-collect-leftover-hours-if-exceeding-8-hours-of-work/m-p/4375327#M173711</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2025-01-22T09:26:57Z</dc:date>
    </item>
  </channel>
</rss>

