<?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: Days that a vehicle was non-operational in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3517715#M135088</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;,&amp;nbsp;I have provided now the sample data! As comented in the link that your refer! Thanks.&lt;/P&gt;</description>
    <pubDate>Mon, 06 Nov 2023 12:33:42 GMT</pubDate>
    <dc:creator>PBITrust</dc:creator>
    <dc:date>2023-11-06T12:33:42Z</dc:date>
    <item>
      <title>Days that a vehicle was non-operational</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3510020#M134677</link>
      <description>&lt;P&gt;Hi there,&lt;BR /&gt;(EDIT: This text have been update)&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Objective&lt;/STRONG&gt;: Return the exact quantity of days that a vehicle havent been operational.&lt;BR /&gt;My DAX:&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&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;NonOperationalDays = 
    DATEDIFF (
        MIN ( pq_fManutencao[Date_StartSO] ) ,
        IF (
            MAX ( pq_fManutencao[Date_EndSO] ) = BLANK() ,
            TODAY() ,
            MAX ( pq_fManutencao[Date_EndSO] )
        )  ,
        DAY
    )&lt;/LI-CODE&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&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Problem: The current enterprise process allow the oppening of multiple Order of Services (O.S), this mean it is creating layers.&lt;BR /&gt;&lt;BR /&gt;A single vehicle can have many OS happening at same time, and my DAX return the exact days per S.O, but not in a vehicle Context.&lt;BR /&gt;The figure bellow show:&lt;BR /&gt;&lt;BR /&gt;Lets say that the Vehicle A in the Farm F have the following exemple:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;OSID&lt;/TD&gt;&lt;TD&gt;Start Date&lt;/TD&gt;&lt;TD&gt;End Date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;OS 1&lt;/TD&gt;&lt;TD&gt;01/11/2023&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;03/11/2023&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;OS 2&lt;/TD&gt;&lt;TD&gt;02/11/2023&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;05/11/2023&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;The vehicle was non operation from 01/11/2023 to 05/11/2023, by this 4 days.&lt;BR /&gt;In Dax it is unprecise, and if we use SUM by diference, it will return OS 1 as 2 days and OS 2 3 days, by this it is 5 days&lt;BR /&gt;&lt;BR /&gt;Link to data sample:&amp;nbsp;&lt;A href="https://multifazendasmf-my.sharepoint.com/:x:/g/personal/johnson_hrenechen_trustagrocompany_com/ERKvLEbkPrVIu0Uz1-qN17IBTjXQqFQHTkMUcQ2-u20Gzw?e=mEtIgD" target="_blank"&gt;SuportePBI (2).xlsx&lt;/A&gt;&lt;BR /&gt;It will expire at 18/11/2023.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 21:50:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3510020#M134677</guid>
      <dc:creator>PBITrust</dc:creator>
      <dc:date>2023-11-07T21:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Days that a vehicle was non-operational</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3515738#M134964</link>
      <description>&lt;P&gt;Please provide sample data (with sensitive information removed) 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). Leave out anything not related to the issue. &lt;BR /&gt;If you are unsure how to do that 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;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;If you want to get answers faster please refer to &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>Sat, 04 Nov 2023 14:05:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3515738#M134964</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-11-04T14:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Days that a vehicle was non-operational</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3517715#M135088</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;,&amp;nbsp;I have provided now the sample data! As comented in the link that your refer! Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 12:33:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3517715#M135088</guid>
      <dc:creator>PBITrust</dc:creator>
      <dc:date>2023-11-06T12:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Days that a vehicle was non-operational</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3517744#M135090</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="640049" data-lia-user-login="PBITrust" class="lia-mention lia-mention-user"&gt;PBITrust&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i don't know i get you or not but&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;look below image&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 12:55:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3517744#M135090</guid>
      <dc:creator>Dangar332</dc:creator>
      <dc:date>2023-11-06T12:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: Days that a vehicle was non-operational</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3517831#M135099</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="569583" data-lia-user-login="Dangar332" class="lia-mention lia-mention-user"&gt;Dangar332&lt;/a&gt;,&amp;nbsp;It seems right! If i get you have SUM the collum of my sample right?&lt;BR /&gt;This (DAX) whas indeed a DAX an not a Calculated Colum, I'm curious if it work as a dax indeed.&lt;BR /&gt;But i will try here the Calculated Colum to see if it works fine with what i need.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 13:54:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3517831#M135099</guid>
      <dc:creator>PBITrust</dc:creator>
      <dc:date>2023-11-06T13:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: Days that a vehicle was non-operational</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3518279#M135117</link>
      <description>&lt;P&gt;By Power Query, i have created a Calculated Column, but the result via SUM, is a acumulated value, to wich is not my intend.&lt;BR /&gt;By the means that this is indeed the days a vehicle was non operational, it isent a non cumulative view, beacuse as a vehicle can have multiple OS happening.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I cant say that the SUM(NonOperationalDays) / PotentialWork days are in the same "page", as the first can by its nature, accumulate alot more days than a week, month, year can haver.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;( A better way to ilustrate is that we have layers of Service Orders (OS), and they can be above one another. And the sum of it bring us a acumulate value, and the desire output is would be a view in a flat way ).&lt;BR /&gt;&lt;BR /&gt;So if i have the same Farm and Vehicle.&lt;BR /&gt;OS 1 Date 01/11/2023 - 02/11/2023&amp;nbsp; (1 day off)&lt;BR /&gt;OS 2 Date 01/11/2023 - 05/11/2023&amp;nbsp; ( 4 days off)&lt;BR /&gt;&lt;BR /&gt;It havent take&amp;nbsp; 5 days, it is 4 flat days.&lt;BR /&gt;Get it?&lt;BR /&gt;If Im not clear, tell me!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 18:07:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3518279#M135117</guid>
      <dc:creator>PBITrust</dc:creator>
      <dc:date>2023-11-06T18:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Days that a vehicle was non-operational</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3518711#M135144</link>
      <description>&lt;P&gt;This is impossible to do in DAX (because there is no UNIONX function - please vote for the idea) but very easy to do in Power Query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
  Source = Excel.Workbook(File.Contents("C:\Users\xxx\Downloads\SuportePBI.xlsx"), null, true), 
  SuportePBI_Table = Source{[Item = "SuportePBI", Kind = "Table"]}[Data], 
  #"Changed Type" = Table.TransformColumnTypes(
    SuportePBI_Table, 
    {
      {"FarmId", type text}, 
      {"VehicleId", Int64.Type}, 
      {"O.S Id", type text}, 
      {"Start Date", type date}, 
      {"End Date", type date}, 
      {"Days non Operational (DAX)", Int64.Type}
    }
  ), 
  #"Grouped Rows" = Table.Group(
    #"Changed Type", 
    {"VehicleId"}, 
    {
      {
        "Rows", 
        each _, 
        type table [
          FarmId = nullable text, 
          VehicleId = nullable number, 
          O.S Id = nullable text, 
          Start Date = nullable date, 
          End Date = nullable date, 
          #"Days non Operational (DAX)" = nullable number
        ]
      }
    }
  ), 
  #"Added Custom1" = Table.AddColumn(
    #"Grouped Rows", 
    "Days non-operative", 
    each List.Count(
      List.Distinct(
        List.Combine(
          Table.AddColumn(
            [Rows], 
            "Custom", 
            each {
              Int64.From([Start Date]) .. Int64.From([End Date] ?? Date.From(DateTime.LocalNow()))
            }
          )[Custom]
        )
      )
    ), 
    Int64.Type
  ), 
  #"Removed Other Columns" = Table.SelectColumns(
    #"Added Custom1", 
    {"VehicleId", "Days non-operative"}
  )
in
  #"Removed Other Columns"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".&amp;nbsp; (make sure to correct the path to the Excel file)&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 00:05:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3518711#M135144</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-11-07T00:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: Days that a vehicle was non-operational</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3519991#M135206</link>
      <description>&lt;P&gt; Hey&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt; thank you for the idea!&amp;nbsp;&lt;BR /&gt;I used a amostral selection of 3 vehicles and the manual counting and the solution isen't working as desired.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;BR /&gt;Better explanation in bellow figure.&lt;BR /&gt;1. The -1 ID has 2 Service Orders, but in a flat view it just from 13 to 16, this means 3 not 4 days.&lt;BR /&gt;&lt;BR /&gt;2. In this case, it has again 2 service orders, but both end the same day, so the&amp;nbsp; result is 0, no day have pass, in this sample we I dont show the beging hour and ending one, but we endeed have it.&lt;BR /&gt;Sorry if i'm being a bad community member, but I havent seen it as needed, as there is no problem in it.&lt;BR /&gt;&lt;BR /&gt;3. We here have 98 days, in four OS that contemplate the sum of the second and first problem.&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If you need more information, or something else just comment me!&lt;BR /&gt;And again thank's for the help!&lt;BR /&gt;&lt;BR /&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;</description>
      <pubDate>Tue, 07 Nov 2023 13:23:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3519991#M135206</guid>
      <dc:creator>PBITrust</dc:creator>
      <dc:date>2023-11-07T13:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: Days that a vehicle was non-operational</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3520081#M135212</link>
      <description>&lt;LI-CODE lang="markup"&gt;just from 13 to 16, this means 3 not 4 days.&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;13,14,15,16 = four days.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 14:07:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3520081#M135212</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-11-07T14:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: Days that a vehicle was non-operational</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3520760#M135250</link>
      <description>&lt;P&gt;It indeed depend on the context, and in this case it is 3 days.&lt;BR /&gt;&lt;BR /&gt;As the time it begun and the time it has end, may not be a cicle of full day, by this understanding and Service Order that has begun at 14hr (4pm) in day 13/10/2023 and ended at 12h (12am) of the 16th day, by this we have 3 days and 22 hours.&lt;BR /&gt;&lt;BR /&gt;As said in my last comment here we have time hours that a Service Orders have begun and ended, but the calculation of the day is the moust trick part by now.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 20:43:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3520760#M135250</guid>
      <dc:creator>PBITrust</dc:creator>
      <dc:date>2023-11-07T20:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Days that a vehicle was non-operational</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3520774#M135251</link>
      <description>&lt;P&gt;There was no time component in your sample data.&amp;nbsp;Please provide sample data &lt;STRONG&gt;that fully covers your issue&lt;/STRONG&gt;.&lt;BR /&gt;Please show the expected outcome based on the sample data you provided.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 20:55:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3520774#M135251</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-11-07T20:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Days that a vehicle was non-operational</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3520855#M135252</link>
      <description>&lt;P&gt;See if it better:&amp;nbsp;&lt;A href="https://multifazendasmf-my.sharepoint.com/:x:/g/personal/johnson_hrenechen_trustagrocompany_com/ERKvLEbkPrVIu0Uz1-qN17IBTjXQqFQHTkMUcQ2-u20Gzw?e=mEtIgD" target="_blank" rel="noopener"&gt;SuportePBI (2).xlsx&lt;/A&gt;&lt;BR /&gt;I belive this will bring an adicional complication. As the hour in or ERP Addon, is been bringing in number, so a 06:00 pm (for my country 06pm is equal 18h and the system will bring 1800.&lt;BR /&gt;For now I'm working in finding a solution for it, wich shall be concluded if all goes alright by tomorrow morning (UTC-8).&lt;BR /&gt;&lt;BR /&gt;So I will reupload a new version of this arquive.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 21:58:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-that-a-vehicle-was-non-operational/m-p/3520855#M135252</guid>
      <dc:creator>PBITrust</dc:creator>
      <dc:date>2023-11-07T21:58:30Z</dc:date>
    </item>
  </channel>
</rss>

