<?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: calculate hours within selected daterange in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-hours-within-selected-daterange/m-p/4081010#M162002</link>
    <description>&lt;P&gt;Hello Rakesh,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanx for your help so far. It is certainly helpful.&lt;/P&gt;&lt;P&gt;and even though it is close, it is not exactly right.&lt;/P&gt;&lt;P&gt;for example, if I would have a run from Jan 1, 0:00 until Jan 2 8:00, and I set my slicer to start on Jan 2 then your solution give me 16 hours (the average of 1 day) where I would need to see 8 hours (Jan 2, from 0:00 until 8:00)&lt;/P&gt;</description>
    <pubDate>Mon, 05 Aug 2024 10:56:34 GMT</pubDate>
    <dc:creator>StefanH74</dc:creator>
    <dc:date>2024-08-05T10:56:34Z</dc:date>
    <item>
      <title>calculate hours within selected daterange</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-hours-within-selected-daterange/m-p/4080557#M161986</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a fact-table with productionruns which contains the start- and end-date &amp;amp; time.&lt;/P&gt;&lt;P&gt;now to calculate the production-duration would be as simple as making a caclulated column&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;PrunTotalTime = vProductionRun[end]-vProductionRun[start]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and then SUM that column&lt;/P&gt;&lt;P&gt;however the problem lies within the fact that these runs can be quite long, in fact longer than the period I want to do calculations on.&lt;/P&gt;&lt;P&gt;I have a Date-table, and a slicer to select the daterange I want to measure.&lt;/P&gt;&lt;P&gt;so my calculation should be something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;PrunTotalTime = MIN(vProductionRun[end],MAX(dimDate,[Date]))-MAX(vProductionRun[start],MIN(dimDate,[Date]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but it needs to do that for all lines seperately, and I cant get that to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as a measure it wont work because it doesnt look at all lines seperately.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as a calculated column it doesnt work because it ignores the setting of the date-slicer and just takes the min- and max-date of the entire date-table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any ideas on how to do this would be greatly appreciated!&lt;/P&gt;&lt;P&gt;Thanx in advance for your contribution,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 08:52:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-hours-within-selected-daterange/m-p/4080557#M161986</guid>
      <dc:creator>StefanH74</dc:creator>
      <dc:date>2024-08-05T08:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: calculate hours within selected daterange</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-hours-within-selected-daterange/m-p/4080632#M161988</link>
      <description>&lt;P&gt;Please post some sample data to help you better.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 09:04:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-hours-within-selected-daterange/m-p/4080632#M161988</guid>
      <dc:creator>SachinNandanwar</dc:creator>
      <dc:date>2024-08-05T09:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: calculate hours within selected daterange</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-hours-within-selected-daterange/m-p/4080982#M162000</link>
      <description>&lt;P&gt;Since I have not any available data, I have created one data set to demonstrate the solution&lt;BR /&gt;Source data&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Creating a Duplicate of the same and rename it as "Start End". Removing start time and end time&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Added a custom column to create a calendar with the in between dates of start and end dates&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Expanded table got 103 rows whereas original table has 18 rows&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Overall hours is calculated in the main table&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Average hours is calculated&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;With the help of lookupvalue formula hours per day against each work in loaded in "Start End" Table&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Final Visualization&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;If this is ok with you please accept the same as your solution.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 10:37:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-hours-within-selected-daterange/m-p/4080982#M162000</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-05T10:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: calculate hours within selected daterange</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-hours-within-selected-daterange/m-p/4081010#M162002</link>
      <description>&lt;P&gt;Hello Rakesh,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanx for your help so far. It is certainly helpful.&lt;/P&gt;&lt;P&gt;and even though it is close, it is not exactly right.&lt;/P&gt;&lt;P&gt;for example, if I would have a run from Jan 1, 0:00 until Jan 2 8:00, and I set my slicer to start on Jan 2 then your solution give me 16 hours (the average of 1 day) where I would need to see 8 hours (Jan 2, from 0:00 until 8:00)&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 10:56:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-hours-within-selected-daterange/m-p/4081010#M162002</guid>
      <dc:creator>StefanH74</dc:creator>
      <dc:date>2024-08-05T10:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: calculate hours within selected daterange</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-hours-within-selected-daterange/m-p/4081034#M162003</link>
      <description>&lt;P&gt;Share the sample data&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 11:12:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-hours-within-selected-daterange/m-p/4081034#M162003</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-05T11:12:43Z</dc:date>
    </item>
  </channel>
</rss>

