<?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: Only Return Work Order Numbers After Amount Is Distributed in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3069893#M106484</link>
    <description>&lt;P&gt;Hey John,&lt;/P&gt;&lt;P&gt;You can find a sample dataset here. I just pulled out a few item codes for you to look at, the one I already mentioned and two more. Also attached a screengrab of what im expecting the other two to look like just like I did for&amp;nbsp; WO 00-201604. Let me know if this link works for you, if not I can try to do it through Google Drive.&lt;/P&gt;&lt;P&gt;Thanks again for the help, we are really stumped!&lt;/P&gt;&lt;P&gt;&lt;A href="https://filebox.mercervalve.net/sharing/LfCiddHev" target="_blank"&gt;https://filebox.mercervalve.net/sharing/LfCiddHev&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Feb 2023 17:55:28 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-02-08T17:55:28Z</dc:date>
    <item>
      <title>Only Return Work Order Numbers After Amount Is Distributed</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3067265#M106257</link>
      <description>&lt;P&gt;Good Day,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am only wanting to return workorders where we didn't have enough quantityonhand to cover the order.&lt;/P&gt;&lt;P&gt;In the example below quantityonhand in IM_ItemWarehouse is 139.&amp;nbsp;&amp;nbsp;I need quantityonhand to be distributed to the QtyCommitted amount in WO2_WorkOrderMaterialDetail in order of earliest to latest WODueDates, this would cover WorkOrder 0082975 leaving 29 left. Then the next earliest date is WorkOrder 0082966 with 108 – leaving me 79 short so I would need to return this (0082966) workorder. The next few WorkOrders have 0 committed so they are not in the report, then it shows WorkOrders 0083655 &amp;amp; 0083646 being short 50 &amp;amp; 42 because there is no qty left to cover it. So what I would need returned are WorkOrders&amp;nbsp;0082966,&amp;nbsp;0083655 &amp;amp; 0083646 with their quantity short amounts. Does anyone know how I can accomplish this?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;IM_ItemWarehouse&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;WO2_WorkOrderMaterialDetail&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;Expected outcome&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much,&lt;/P&gt;&lt;P&gt;Lydia&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 15:04:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3067265#M106257</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-08T15:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Only Return Work Order Numbers After Amount Is Distributed</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3068681#M106373</link>
      <description>&lt;P&gt;You could create a measure like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Shortfall =
SUMX (
    WO2_WorkOrderMaterialDetail,
    VAR QuantityOnHand =
        RELATED ( IM_ItemWarehouse[QuantityOnHand] )
    VAR RequiredAmount = WO2_WorkOrderMaterialDetail[QtyCommitted]
    VAR CurrentDate = WO2_WorkOrderMaterialDetail[WO_Due_Date]
    VAR PreviouslyUsed =
        CALCULATE (
            SUM ( WO2_WorkOrderMaterialDetail[QtyCommitted] ),
            ALLEXCEPT (
                WO2_WorkOrderMaterialDetail,
                WO2_WorkOrderMaterialDetail[ComponentID]
            ),
            WO2_WorkOrderMaterialDetail[WO_Due_Date] &amp;lt; CurrentDate
        )
    VAR AvailableStock =
        MAX ( QuantityOnHand - PreviouslyUsed, 0 )
    RETURN
        RequiredAmount - AvailableStock
)
&lt;/LI-CODE&gt;
&lt;P&gt;and then use this in a table visual with the work order number, and filter it to only show when the value is &amp;gt; 0&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 10:38:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3068681#M106373</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-02-08T10:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Only Return Work Order Numbers After Amount Is Distributed</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3069616#M106451</link>
      <description>&lt;P&gt;Jolly Morning John,&lt;BR /&gt;&lt;BR /&gt;This looks to almost be what I need! &lt;span class="lia-unicode-emoji" title=":sign_of_the_horns:"&gt;🤘&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Could you help me finishing it? Here is an example of what I am expecting the table to look like&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have a 26 of these on hand currently and here are all my orders that would need that amount distributed out.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Youll see once you get to WO HY910-1 I already have 25 of the total 26 distributed out. Meaning that there is only 1 left to fill the 2 required (QTYCommited column). So I would expect to see the shortfall amount = 1. Instead I am getting -16. Here is what I am getting in my table visual after dragging all my fields in.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Any other suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 16:25:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3069616#M106451</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-08T16:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Only Return Work Order Numbers After Amount Is Distributed</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3069660#M106454</link>
      <description>&lt;P&gt;Not sure how its returning negative numbers at all. Can you share some sample data via dropbox or Google Drive or similar ?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 16:37:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3069660#M106454</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-02-08T16:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Only Return Work Order Numbers After Amount Is Distributed</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3069893#M106484</link>
      <description>&lt;P&gt;Hey John,&lt;/P&gt;&lt;P&gt;You can find a sample dataset here. I just pulled out a few item codes for you to look at, the one I already mentioned and two more. Also attached a screengrab of what im expecting the other two to look like just like I did for&amp;nbsp; WO 00-201604. Let me know if this link works for you, if not I can try to do it through Google Drive.&lt;/P&gt;&lt;P&gt;Thanks again for the help, we are really stumped!&lt;/P&gt;&lt;P&gt;&lt;A href="https://filebox.mercervalve.net/sharing/LfCiddHev" target="_blank"&gt;https://filebox.mercervalve.net/sharing/LfCiddHev&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 17:55:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3069893#M106484</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-08T17:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Only Return Work Order Numbers After Amount Is Distributed</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3069940#M106489</link>
      <description>&lt;P&gt;It appears that link isnt working, here it is in google drive:&amp;nbsp;&lt;A href="https://drive.google.com/drive/folders/1Vtg1ziC7lYcPFPIDSZ-XKQWSPVyQdd-Q?usp=sharing" target="_blank"&gt;https://drive.google.com/drive/folders/1Vtg1ziC7lYcPFPIDSZ-XKQWSPVyQdd-Q?usp=sharing&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 18:21:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3069940#M106489</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-08T18:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: Only Return Work Order Numbers After Amount Is Distributed</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3071496#M106639</link>
      <description>&lt;P&gt;OK, one of the issues is that the date isn't a low enough granularity to do comparisons on, because there are multiple orders for the same item on the same day. You need another column, preferably numeric, which is unique for each row and can be used to determine the order. If you don't have one in the source data you can create one in Power Query. I did it by sorting the table by date and then work order with the M code below&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Excel.Workbook(File.Contents(""), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"WorkOrder", type text}, {"PreviousIndexNumber", Int64.Type}, {"LinkToNextLine", Int64.Type}, {"Revision", type text}, {"StepNumber", Int64.Type}, {"UM", type text}, {"ItemDescription", type text}, {"Whse", Int64.Type}, {"ComponentItemNumber", type text}, {"QtyParent", Int64.Type}, {"UMconversion", Int64.Type}, {"UnitCost", type number}, {"ScrapPercent", Int64.Type}, {"ExtdQtyRequired", Int64.Type}, {"QtyIssued", Int64.Type}, {"QtyCommitted", Int64.Type}, {"DirectCosts", Int64.Type}, {"FixedOvhdCosts", Int64.Type}, {"VariableOvhdCosts", Int64.Type}, {"StdFixedOverheadAmount", Int64.Type}, {"StdVarOverheadAmount", Int64.Type}, {"WODueDate_CC", type date}, {"OrderStatus", type text}}),
    #"Sorted Rows" = Table.Sort(#"Changed Type",{{"WODueDate_CC", Order.Ascending}, {"WorkOrder", Order.Ascending}}),
    #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 1, 1, Int64.Type)
in
    #"Added Index"&lt;/LI-CODE&gt;
&lt;P&gt;Its just the last 2 steps you need really.&lt;/P&gt;
&lt;P&gt;Once you have that column you can change the measure to be&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Shortfall = SUMX(
	'WO2_WorkOrderMaterialDetail',
	VAR QuantityOnHand =
		RELATED( 'IM_ItemWarehouse'[QuantityOnHand] )
	VAR RequiredAmount =
		'WO2_WorkOrderMaterialDetail'[QtyCommitted]
	VAR CurrentIndex = 'WO2_WorkOrderMaterialDetail'[Index]
	VAR PreviouslyUsed =
		CALCULATE(
			SUM( 'WO2_WorkOrderMaterialDetail'[QtyCommitted] ),
			ALLEXCEPT(
				'WO2_WorkOrderMaterialDetail',
				'WO2_WorkOrderMaterialDetail'[ComponentItemNumber]
			),
			'WO2_WorkOrderMaterialDetail'[Index] &amp;lt; CurrentIndex
		)
	VAR AvailableStock = MAX( QuantityOnHand - PreviouslyUsed, 0 )
	RETURN
		MAX( RequiredAmount - AvailableStock, 0 )
)&lt;/LI-CODE&gt;
&lt;P&gt;This now uses the new index column and I also tweaked the return statement so that it won't return negative numbers.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 09:55:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3071496#M106639</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-02-09T09:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Only Return Work Order Numbers After Amount Is Distributed</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3080060#M107303</link>
      <description>&lt;P&gt;So this works perfectly for us, issue is that this is so demanding it crashes every visual I try to put it in (matrix or table). Could you think of any other route to go about this? Any advicce would be helpful, thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 18:02:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3080060#M107303</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-14T18:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Only Return Work Order Numbers After Amount Is Distributed</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3081116#M107390</link>
      <description>&lt;P&gt;You could try turning it into a calculated column instead of a measure, that way everything only needs to get calculated during data refresh&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Shortfall =
VAR QuantityOnHand =
    RELATED ( 'IM_ItemWarehouse'[QuantityOnHand] )
VAR RequiredAmount = 'WO2_WorkOrderMaterialDetail'[QtyCommitted]
VAR CurrentIndex = 'WO2_WorkOrderMaterialDetail'[Index]
VAR PreviouslyUsed =
    CALCULATE (
        SUM ( 'WO2_WorkOrderMaterialDetail'[QtyCommitted] ),
        ALLEXCEPT (
            'WO2_WorkOrderMaterialDetail',
            'WO2_WorkOrderMaterialDetail'[ComponentItemNumber]
        ),
        'WO2_WorkOrderMaterialDetail'[Index] &amp;lt; CurrentIndex
    )
VAR AvailableStock =
    MAX ( QuantityOnHand - PreviouslyUsed, 0 )
RETURN
    MAX ( RequiredAmount - AvailableStock, 0 )
&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 15 Feb 2023 09:14:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3081116#M107390</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-02-15T09:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Only Return Work Order Numbers After Amount Is Distributed</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3081879#M107462</link>
      <description>&lt;P&gt;This doesnt work for me unfortunately, I keep getting an error saying the memory is insufficent to do it:/ Same as it was when I tried to put it in the visual. Thank you for all your help though, you did indeed give the right answer I just think my computer cannot handle this.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 16:58:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Only-Return-Work-Order-Numbers-After-Amount-Is-Distributed/m-p/3081879#M107462</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-15T16:58:02Z</dc:date>
    </item>
  </channel>
</rss>

