<?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: Aggregating and Visualising Duration Data in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-and-Visualising-Duration-Data/m-p/4006076#M156809</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="209480" data-lia-user-login="mobul" class="lia-mention lia-mention-user"&gt;mobul&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create measures.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Format 1 = 
var _a=[total hoursWorked per dept per month]
var _b=ROUNDDOWN(_a,0)
var _c=_a-_b
return  SWITCH(TRUE(),
_b=0,_c*60 &amp;amp; "m",
_c=0, _b&amp;amp; "h",
_b&amp;amp;"h"&amp;amp;(_a-_b)*60&amp;amp;"m")&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Format 2 = 
var _a=[total hoursWorked per employeeID per month]
var _b=ROUNDDOWN(_a,0)
var _c=_a-_b
return  SWITCH(TRUE(),
_b=0,_c*60 &amp;amp; "m",
_c=0, _b&amp;amp; "h",
_b&amp;amp;"h"&amp;amp;(_a-_b)*60&amp;amp;"m")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Neeko Tang&lt;/P&gt;
&lt;P&gt;If this post  &lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution &lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jun 2024 03:06:59 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-06-24T03:06:59Z</dc:date>
    <item>
      <title>Aggregating and Visualising Duration Data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-and-Visualising-Duration-Data/m-p/4002349#M156088</link>
      <description>&lt;P&gt;I have some data showing the number of hours worked but I'm not clear what modelling or formatting I need to do to be able to aggregate it and visualise it in PowerBI.&lt;/P&gt;&lt;P&gt;In power query editor I have 6 columns with the startTime &amp;amp; endTime as type &lt;EM&gt;Time&lt;/EM&gt; and hours as type &lt;EM&gt;duration&lt;/EM&gt;. The duration was not calculated, it was ingested.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Restriction&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I have to use a particular version of PBI desktop that doesn't have dynamic formatting&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;&lt;STRONG&gt;EmployeeID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Dept&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;startTime&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;endTime&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;hoursWorked&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;abcd&lt;/TD&gt;&lt;TD&gt;dept1&lt;/TD&gt;&lt;TD&gt;01/01/2020&lt;/TD&gt;&lt;TD&gt;09:00:00&lt;/TD&gt;&lt;TD&gt;20:00:00&lt;/TD&gt;&lt;TD&gt;0.11:00:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;abcd&lt;/TD&gt;&lt;TD&gt;dept1&lt;/TD&gt;&lt;TD&gt;02/01/2020&lt;/TD&gt;&lt;TD&gt;09:00:00&lt;/TD&gt;&lt;TD&gt;20:15:00&lt;/TD&gt;&lt;TD&gt;0.11:15:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;jkl&lt;/TD&gt;&lt;TD&gt;dept1&lt;/TD&gt;&lt;TD&gt;01/01/2020&lt;/TD&gt;&lt;TD&gt;17:45:00&lt;/TD&gt;&lt;TD&gt;18:15:00&lt;/TD&gt;&lt;TD&gt;0.00:30:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;jkl&lt;/TD&gt;&lt;TD&gt;dept2&lt;/TD&gt;&lt;TD&gt;01/03/2020&lt;/TD&gt;&lt;TD&gt;15:00:00&lt;/TD&gt;&lt;TD&gt;15:30:00&lt;/TD&gt;&lt;TD&gt;0.00:30:00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to be able to visualise as charts&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;total hoursWorked per employeeID per month&lt;/LI&gt;&lt;LI&gt;total hoursWorked&amp;nbsp;per dept per month&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;My issues are the &lt;/STRONG&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;hoursWorked&amp;nbsp;column doesn't support sum (just count or count distinct) in the designer. In Power Query its type is duration, in report designer its data type is Time and there is no duration option.&lt;/LI&gt;&lt;LI&gt;If i duplicate the hours and change it to type decimal then I can sum but can't figure out how to&lt;OL&gt;&lt;LI&gt;ensure the result is accurate&lt;/LI&gt;&lt;LI&gt;format the result so its user friendly in days, hours mins.&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;Not clear what limitations apply or features exist that could help me&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;STRONG&gt;What I have tried.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Duplicating the hoursWorked value as a decimal&lt;/P&gt;&lt;P&gt;Creating a Measure SumFormatted =&amp;nbsp;&lt;SPAN&gt;format&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'2019 to 2023'&lt;/SPAN&gt;&lt;SPAN&gt;[hoursWorked]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;"dd \d &lt;/SPAN&gt;&lt;SPAN&gt;hh\h:mm:ss"&lt;/SPAN&gt;&lt;SPAN&gt;) which is returned as text but is returning a different result to the decimal sum assuming the int value represents days (24hours)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any advice welcome on the power query, measures needed and limitations&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 15:06:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-and-Visualising-Duration-Data/m-p/4002349#M156088</guid>
      <dc:creator>mobul</dc:creator>
      <dc:date>2024-06-20T15:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating and Visualising Duration Data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-and-Visualising-Duration-Data/m-p/4003074#M156150</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="209480" data-lia-user-login="mobul" class="lia-mention lia-mention-user"&gt;mobul&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your description, here are my steps you can follow as a solution.&lt;/P&gt;
&lt;P&gt;(1) My test data is the same as yours.&lt;/P&gt;
&lt;P&gt;(2) We can create calculated columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;hoursWorked (h) = 
 var _start=CONVERT([Date]&amp;amp;" "&amp;amp;[startTime],DATETIME)
 var _end=CONVERT([Date]&amp;amp;" "&amp;amp;[endTime],DATETIME)
 RETURN DATEDIFF(_start,_end,SECOND)/3600&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Month = MONTH([Date])&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Year = YEAR([Date])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(3) We can create measures.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;total hoursWorked per dept per month =
CALCULATE (
    SUM ( 'Table'[hoursWorked (h)] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        [Dept] = MAX ( 'Table'[Dept] )
            &amp;amp;&amp;amp; [Year]
                IN VALUES ( 'Table'[Year] )
                    &amp;amp;&amp;amp; [Month] IN VALUES ( 'Table'[Month] )
    )
)

&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;total hoursWorked per employeeID per month =
CALCULATE (
    SUM ( 'Table'[hoursWorked (h)] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        [EmployeeID] = MAX ( 'Table'[EmployeeID] )
            &amp;amp;&amp;amp; [Year]
                IN VALUES ( 'Table'[Year] )
                    &amp;amp;&amp;amp; [Month] IN VALUES ( 'Table'[Month] )
    )
)

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(4) Then the result is as follows.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Neeko Tang&lt;/P&gt;
&lt;P&gt;If this post  &lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution &lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2024 03:12:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-and-Visualising-Duration-Data/m-p/4003074#M156150</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-21T03:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating and Visualising Duration Data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-and-Visualising-Duration-Data/m-p/4003884#M156234</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;thanks for the help and thanks for the very clear response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the benefit of creating measures when you sum the decimal value of the duration in seconds which you created as a calculated field instead of duplicating the worksWorked and transforming it into TotalSeconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also is there any way to show the values in hours and mins e.g. 11.00 is 11hr 00mins, 11.50 is 11hrs 30mins? My reason is its easier for readers but also when there is more data and hoursWorked then goes over 24hrs i think it makes more sense to talk about days worked instead of hours days&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2024 10:39:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-and-Visualising-Duration-Data/m-p/4003884#M156234</guid>
      <dc:creator>mobul</dc:creator>
      <dc:date>2024-06-21T10:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating and Visualising Duration Data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-and-Visualising-Duration-Data/m-p/4006076#M156809</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="209480" data-lia-user-login="mobul" class="lia-mention lia-mention-user"&gt;mobul&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create measures.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Format 1 = 
var _a=[total hoursWorked per dept per month]
var _b=ROUNDDOWN(_a,0)
var _c=_a-_b
return  SWITCH(TRUE(),
_b=0,_c*60 &amp;amp; "m",
_c=0, _b&amp;amp; "h",
_b&amp;amp;"h"&amp;amp;(_a-_b)*60&amp;amp;"m")&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Format 2 = 
var _a=[total hoursWorked per employeeID per month]
var _b=ROUNDDOWN(_a,0)
var _c=_a-_b
return  SWITCH(TRUE(),
_b=0,_c*60 &amp;amp; "m",
_c=0, _b&amp;amp; "h",
_b&amp;amp;"h"&amp;amp;(_a-_b)*60&amp;amp;"m")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Neeko Tang&lt;/P&gt;
&lt;P&gt;If this post  &lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution &lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 03:06:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-and-Visualising-Duration-Data/m-p/4006076#M156809</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-24T03:06:59Z</dc:date>
    </item>
  </channel>
</rss>

