<?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 DAX for Time in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-for-Time/m-p/3986565#M154544</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to gather metrics on completion times in Power BI. I want to see this in Hours and Minutes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried a few solutions that "work" but don't work to what we are trying to achieve.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting the time as a decimal number by subracting a created on date and a resolution date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example: A case Created on 6/8 at 6am and Resolved on 6/9 at 6pm would give me a 1.5 for 1.5 days&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first solution I did and really liked was a dax like this&lt;BR /&gt;&amp;nbsp;CaseResTime =&lt;BR /&gt;VAR ElapsedTime = Case time (which is my DateDiff column)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR days = INT(ElapsedTime)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR _hrs = (ElapsedTime - days)*24&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR hrs = INT(_hrs)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR mins = ROUNDD((_hrs - hrs)*60,0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;days &amp;amp; "D" &amp;amp; hrs &amp;amp; "H" &amp;amp; mins &amp;amp; "M"&lt;BR /&gt;&lt;BR /&gt;This looked great easy to read and explanitory 1D12H28M&amp;nbsp; &amp;nbsp;Something like that but my problem was I couldn't average it because it isn't a "Number"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I switched my thinking here and want to get it to now just be a decimal numeber (Hours).(Mins) so I wrote this DAX Statement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;CaseResTime =&lt;BR /&gt;VAR ElapsedTime = Case time (which is my DateDiff column)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR days = INT(ElapsedTime)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR _hrs = (ElapsedTime - days)*24&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR dayshrs = days *24&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR CaseHours = dayshrs + _hrs&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR WholeCaseHr = INT(CaseHours)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR Minutes = (CaseHours - WholeCaseHr) *0.01&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR AcurateMin = Minutes*60&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WholeCaseHr + AccurateMin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is giving me what I want like 1.30 is 1 hour 30 min&amp;nbsp; &amp;nbsp; &amp;nbsp;but when I average this it gets messy. Ideally you wouldnt see above .59 on anything because that would be 59 minutes but averaging things out some&amp;nbsp; employees have outcomes saying 3.75&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if there are any easier ways to achieve what I am trying to do.&lt;BR /&gt;&lt;BR /&gt;Hopefully I gave enough details.&amp;nbsp; Thank you for looking into this question.&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jun 2024 16:34:36 GMT</pubDate>
    <dc:creator>MrBlackEyE31</dc:creator>
    <dc:date>2024-06-11T16:34:36Z</dc:date>
    <item>
      <title>DAX for Time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-for-Time/m-p/3986565#M154544</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to gather metrics on completion times in Power BI. I want to see this in Hours and Minutes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried a few solutions that "work" but don't work to what we are trying to achieve.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting the time as a decimal number by subracting a created on date and a resolution date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example: A case Created on 6/8 at 6am and Resolved on 6/9 at 6pm would give me a 1.5 for 1.5 days&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first solution I did and really liked was a dax like this&lt;BR /&gt;&amp;nbsp;CaseResTime =&lt;BR /&gt;VAR ElapsedTime = Case time (which is my DateDiff column)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR days = INT(ElapsedTime)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR _hrs = (ElapsedTime - days)*24&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR hrs = INT(_hrs)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR mins = ROUNDD((_hrs - hrs)*60,0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;days &amp;amp; "D" &amp;amp; hrs &amp;amp; "H" &amp;amp; mins &amp;amp; "M"&lt;BR /&gt;&lt;BR /&gt;This looked great easy to read and explanitory 1D12H28M&amp;nbsp; &amp;nbsp;Something like that but my problem was I couldn't average it because it isn't a "Number"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I switched my thinking here and want to get it to now just be a decimal numeber (Hours).(Mins) so I wrote this DAX Statement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;CaseResTime =&lt;BR /&gt;VAR ElapsedTime = Case time (which is my DateDiff column)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR days = INT(ElapsedTime)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR _hrs = (ElapsedTime - days)*24&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR dayshrs = days *24&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR CaseHours = dayshrs + _hrs&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR WholeCaseHr = INT(CaseHours)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR Minutes = (CaseHours - WholeCaseHr) *0.01&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR AcurateMin = Minutes*60&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WholeCaseHr + AccurateMin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is giving me what I want like 1.30 is 1 hour 30 min&amp;nbsp; &amp;nbsp; &amp;nbsp;but when I average this it gets messy. Ideally you wouldnt see above .59 on anything because that would be 59 minutes but averaging things out some&amp;nbsp; employees have outcomes saying 3.75&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if there are any easier ways to achieve what I am trying to do.&lt;BR /&gt;&lt;BR /&gt;Hopefully I gave enough details.&amp;nbsp; Thank you for looking into this question.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 16:34:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-for-Time/m-p/3986565#M154544</guid>
      <dc:creator>MrBlackEyE31</dc:creator>
      <dc:date>2024-06-11T16:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: DAX for Time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-for-Time/m-p/3987125#M154559</link>
      <description>&lt;P&gt;You need to do all your math with decimals, and then at the very last minute reformat it to display as a duration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide sample data that covers your issue or question &lt;STRONG&gt;completely&lt;/STRONG&gt;, in a &lt;STRONG&gt;usable&lt;/STRONG&gt; format (not as a screenshot).&lt;BR /&gt;&lt;BR /&gt;Do not include sensitive information or anything not related to the issue or question. &lt;BR /&gt;&lt;BR /&gt;If you are unsure how to upload data please refer to &lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;Want faster answers? &lt;A href="https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 00:41:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-for-Time/m-p/3987125#M154559</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-06-12T00:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: DAX for Time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-for-Time/m-p/3992808#M154979</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="747617" data-lia-user-login="MrBlackEyE31" class="lia-mention lia-mention-user"&gt;MrBlackEyE31&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;An update on this? Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;How to Get Your Question Answered Quickly&amp;nbsp;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Xiaoxin Sheng&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2024 07:48:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-for-Time/m-p/3992808#M154979</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-14T07:48:34Z</dc:date>
    </item>
  </channel>
</rss>

