<?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: Number of active day between a time frame in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-active-day-between-a-time-frame/m-p/3642435#M141016</link>
    <description>&lt;P&gt;Hi Thanks so much it works as per description. However, is there a way to calculate the no of days based on the date filter rather than the fixed date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g if filter is: 1/2/2023 to 1/10/2023 then the different would be between from the date minus 1/2/2023 (instead of the fixed date 1/1/2023), similarly with the 1/10/2023 instead of 31/12/2023.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks heaps,&lt;/P&gt;</description>
    <pubDate>Wed, 17 Jan 2024 04:03:36 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-01-17T04:03:36Z</dc:date>
    <item>
      <title>Number of active day between a time frame</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-active-day-between-a-time-frame/m-p/3631955#M140480</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to calculate the number of days a machine is turned on between a period of time, please refer to the screenshot below. Much appreciated any suggesstion. Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 03:56:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-active-day-between-a-time-frame/m-p/3631955#M140480</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-11T03:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Number of active day between a time frame</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-active-day-between-a-time-frame/m-p/3632137#M140485</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Can you share some sample data with the desired output to have a clear understanding of your question?&lt;BR /&gt;You can either paste your data in the reply box or&amp;nbsp;save it in OneDrive, Google Drive, or any other cloud-sharing platform and share the link here.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 04:48:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-active-day-between-a-time-frame/m-p/3632137#M140485</guid>
      <dc:creator>Fowmy</dc:creator>
      <dc:date>2024-01-11T04:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Number of active day between a time frame</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-active-day-between-a-time-frame/m-p/3632597#M140498</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for looking into it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the data, the first 3 columns:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Machine No&lt;/TD&gt;&lt;TD&gt;Active&lt;/TD&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Calculate No of active days&lt;/TD&gt;&lt;TD&gt;Note Only&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC&lt;/TD&gt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;&lt;TR&gt;&lt;TD&gt;XYZ&lt;/TD&gt;&lt;TD&gt;Off&lt;/TD&gt;&lt;TD&gt;9/07/2023&lt;/TD&gt;&lt;TD&gt;126&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;DEF&lt;/TD&gt;&lt;TD&gt;On&lt;/TD&gt;&lt;TD&gt;5/08/2022&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;DEF&lt;/TD&gt;&lt;TD&gt;Off&lt;/TD&gt;&lt;TD&gt;9/07/2023&lt;/TD&gt;&lt;TD&gt;189&lt;/TD&gt;&lt;TD&gt;Since ON day is earlier than the filter range, active day = OFF date - From date (in filter)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;DEF&lt;/TD&gt;&lt;TD&gt;On&lt;/TD&gt;&lt;TD&gt;1/08/2023&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;DEF&lt;/TD&gt;&lt;TD&gt;Off&lt;/TD&gt;&lt;TD&gt;1/09/2023&lt;/TD&gt;&lt;TD&gt;31&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;DEF&lt;/TD&gt;&lt;TD&gt;On&lt;/TD&gt;&lt;TD&gt;10/09/2023&lt;/TD&gt;&lt;TD&gt;112&lt;/TD&gt;&lt;TD&gt;Since OFF day is after the filter range, active day = To date (in filter) - ON date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;DEF&lt;/TD&gt;&lt;TD&gt;OFF&lt;/TD&gt;&lt;TD&gt;10/04/2024&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here is the expected result when filter range is between 1/1/2023 to 31/12/2023&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Machine No&lt;/TD&gt;&lt;TD&gt;No of active days&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;TD&gt;187&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;XYZ&lt;/TD&gt;&lt;TD&gt;126&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;DEF&lt;/TD&gt;&lt;TD&gt;313&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, the number of active day equal the date when machine is turn off minus the date when the machine is turn on. There are 2 exceptions:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If the Off date is not in the filter range: active day = ON date minus the FROM date (in FIlter)&lt;/LI&gt;&lt;LI&gt;If the ON date is not in the filter range: active day = TO date (in filter) minus OFF date.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 07:18:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-active-day-between-a-time-frame/m-p/3632597#M140498</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-11T07:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Number of active day between a time frame</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-active-day-between-a-time-frame/m-p/3632602#M140499</link>
      <description>&lt;P&gt;Sorry got it the other way around for exception:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If the Off date is not in the filter range: active day = TO date (in filter) minus OFF date&lt;/LI&gt;&lt;LI&gt;If the ON date is not in the filter range: active day =&amp;nbsp;ON date minus the FROM date (in Filter)&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Thu, 11 Jan 2024 07:21:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-active-day-between-a-time-frame/m-p/3632602#M140499</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-11T07:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Number of active day between a time frame</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-active-day-between-a-time-frame/m-p/3634609#M140604</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on the information you have provided, Here are my answers to your questions.&lt;/P&gt;
&lt;P&gt;1. Create a table based on your needs.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp;Write two calculated columns, enter the appropriate DAX code block and do a little integration to get Calculate No of active days.&lt;/P&gt;
&lt;P&gt;No =&lt;/P&gt;
&lt;P&gt;var _1=&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MAXX(FILTER('Table','Table'[Machine No]=EARLIER('Table'[Machine No])&amp;amp;&amp;amp;'Table'[_maxdateoff]=EARLIER('Table'[_maxdateoff])),'Table'[No of active days])&lt;/P&gt;
&lt;P&gt;var __maxdateyear=&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;YEAR('Table'[_maxdateoff])&lt;/P&gt;
&lt;P&gt;var _dateyear=&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;YEAR('Table'[Date])&lt;/P&gt;
&lt;P&gt;return&lt;/P&gt;
&lt;P&gt;IF('Table'[Active]="On",BLANK(),IF(YEAR(__maxdateyear)&amp;lt;&amp;gt;YEAR('Table'[Date]),_1))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No of active days =&lt;/P&gt;
&lt;P&gt;var _maxdateoff=&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; CALCULATE(min('Table'[Date]),FILTER('Table','Table'[Date]&amp;gt;=EARLIER('Table'[Date])&amp;amp;&amp;amp;'Table'[Active]="Off"&amp;amp;&amp;amp;'Table'[Machine No]=EARLIER('Table'[Machine No])))&lt;/P&gt;
&lt;P&gt;var _1=&lt;/P&gt;
&lt;P&gt;IF(YEAR(_maxdateoff)=YEAR('Table'[Date]),DATEDIFF('Table'[Date],_maxdateoff,DAY),IF(YEAR(_maxdateoff)=2023,DATEDIFF(DATE(2023,1,1),_maxdateoff,DAY),IF(YEAR(_maxdateoff)=2024,DATEDIFF('Table'[Date],DATE(2023,12,31),DAY))))&lt;/P&gt;
&lt;P&gt;Return&lt;/P&gt;
&lt;P&gt;_1&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3.&amp;nbsp;You can see the final result you need in the visualization.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 6.0pt 0in 0in 0in;"&gt;&lt;A title="https://community.powerbi.com/t5/community-blog/how-to-get-your-question-answered-quickly/ba-p/38490" href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-Get-Your-Question-Answered-Quickly%2Fba-p%2F38490&amp;amp;data=05%7C02%7Cv-yilongzhou%40microsoft.com%7C7786ec63b72b4832018f08dc130e7296%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638406200002193477%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=pyPkIEYlTMwvHWQ7h60yHlOoJjpkt3p09DgGn4cUSdo%3D&amp;amp;reserved=0" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;How to Get Your Question Answered Quickly&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 6.0pt 0in 0in 0in;"&gt;&lt;SPAN&gt;If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 6.0pt;"&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 6.0pt;"&gt;&lt;SPAN&gt;Yilong Zhou&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 6.0pt;"&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 01:44:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-active-day-between-a-time-frame/m-p/3634609#M140604</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-12T01:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: Number of active day between a time frame</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-active-day-between-a-time-frame/m-p/3642435#M141016</link>
      <description>&lt;P&gt;Hi Thanks so much it works as per description. However, is there a way to calculate the no of days based on the date filter rather than the fixed date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g if filter is: 1/2/2023 to 1/10/2023 then the different would be between from the date minus 1/2/2023 (instead of the fixed date 1/1/2023), similarly with the 1/10/2023 instead of 31/12/2023.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks heaps,&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 04:03:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-active-day-between-a-time-frame/m-p/3642435#M141016</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-17T04:03:36Z</dc:date>
    </item>
  </channel>
</rss>

