<?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 number of top rows with sum of their values equal to a particular dynamic value in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045826#M45950</link>
    <description>&lt;P&gt;Well, Greg, it looks like PQ enters the stage &lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Aug 2021 10:02:03 GMT</pubDate>
    <dc:creator>daxer-almighty</dc:creator>
    <dc:date>2021-08-30T10:02:03Z</dc:date>
    <item>
      <title>Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2044369#M45918</link>
      <description>&lt;P&gt;I have a table of Sales Order Details which has a Sales Order Number Column, Item Code Column and Quantity Ordered column. Let us call this &lt;STRONG&gt;SalesOrders&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;OrderNo&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;ItemCode&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;QtyOrd&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;S1&lt;/TD&gt;&lt;TD&gt;A1&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;S1&lt;/TD&gt;&lt;TD&gt;B1&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;S1&lt;/TD&gt;&lt;TD&gt;A2&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;S2&lt;/TD&gt;&lt;TD&gt;A1&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;S2&lt;/TD&gt;&lt;TD&gt;A2&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;S3&lt;/TD&gt;&lt;TD&gt;B1&lt;/TD&gt;&lt;TD&gt;14&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have another table which has columns of Item Code, Location Code and Quantity. This table has details of in which location a particular item is stored and in which quantity. Lets call this&amp;nbsp;&lt;STRONG&gt;Inventory&amp;nbsp;&lt;/STRONG&gt;Table.&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Location&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;ItemCode&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;QtyStr&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;L1&lt;/TD&gt;&lt;TD&gt;A1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;L1&lt;/TD&gt;&lt;TD&gt;A2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;L1&lt;/TD&gt;&lt;TD&gt;B1&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;L2&lt;/TD&gt;&lt;TD&gt;A1&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;L2&lt;/TD&gt;&lt;TD&gt;A2&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;L2&lt;/TD&gt;&lt;TD&gt;B1&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;L3&lt;/TD&gt;&lt;TD&gt;A1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;L3&lt;/TD&gt;&lt;TD&gt;A2&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;L3&lt;/TD&gt;&lt;TD&gt;B1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want calculate --&amp;gt; For each sales order, for each item in that order, how many locations are required to fulfill that item requirement in that order. The locations with highest quantity should be checked first. So want to have a calculated column in &lt;STRONG&gt;SalesOrder&amp;nbsp;&lt;/STRONG&gt;where each row has the number of rows from&amp;nbsp;&lt;STRONG&gt;Inventory&lt;/STRONG&gt;&amp;nbsp;to sum up the&amp;nbsp;&lt;STRONG&gt;QtyOrd &lt;/STRONG&gt;value(starting from the location with highest quantity).&amp;nbsp;&lt;BR /&gt;Also, I want another column with location names which will fulfll that item order.&lt;BR /&gt;I hope I have explained my question clearly.&lt;BR /&gt;&lt;BR /&gt;Kindly help&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="291628" data-lia-user-login="Jihwan_Kim" class="lia-mention lia-mention-user"&gt;Jihwan_Kim&lt;/a&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="255913" data-lia-user-login="daxer-almighty" class="lia-mention lia-mention-user"&gt;daxer-almighty&lt;/a&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="150936" data-lia-user-login="PaulOlding" class="lia-mention lia-mention-user"&gt;PaulOlding&lt;/a&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="52518" data-lia-user-login="Fowmy" class="lia-mention lia-mention-user"&gt;Fowmy&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Aug 2021 15:29:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2044369#M45918</guid>
      <dc:creator>manuvats</dc:creator>
      <dc:date>2021-08-29T15:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2044411#M45919</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="314899" data-lia-user-login="manuvats" class="lia-mention lia-mention-user"&gt;manuvats&lt;/a&gt;&amp;nbsp;Each each row in SalesOrder independent of the other rows or are they dependent? In other words, if for the S1 A1 10 in your first table, I calculate thate I need L1 and L2, can I no longer use the L1 for A1 items like for the S2 A1 20 line?&lt;/P&gt;</description>
      <pubDate>Sun, 29 Aug 2021 15:38:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2044411#M45919</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-08-29T15:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2044414#M45920</link>
      <description>&lt;P&gt;That is a good question and I haven't thought of that. I will ask the concerned team. For the time being, please treat fulfillment of orders independent of each other. The items in a particular location&amp;nbsp;are replenished quickly after fulfillment of an order.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Aug 2021 15:47:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2044414#M45920</guid>
      <dc:creator>manuvats</dc:creator>
      <dc:date>2021-08-29T15:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2044441#M45921</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="314899" data-lia-user-login="manuvats" class="lia-mention lia-mention-user"&gt;manuvats&lt;/a&gt;&amp;nbsp;OK, it is a bit messy and I will explain what is going on. Column is for the count and Column1 is for the list of locations. Now, DAX isn't great at sort orders, in fact by and large sort order is not guaranteed when dealing with DAX. We really can't use EVALUATE and ORDER BY in Power BI Desktop. However, CONCATENATEX does provide us something that can guarantee sort order. So, basically, I create SearchText that concatenates our locations together in the correct sort order by qty. Now, since I used CONCATENATEX, I need to convert things back into a table of values. That's the text to table pattern and essentially that is encapsulated in the calculation of __Table. So you can kind of ignore that because that's what that is doing. Now, for the Table1 variable, I am taking my converted list of Locations in a table in the correct sort order and I first add a running total so that I know how much inventory I have at that location including the inventory at locations with more inventory than the current location. I then add a column to decrement the sales order amount. Next, __Index finds the minimum index of the location where the decrement is still greater than or equal to zero. This is the first location where the running total meets the demand. After that it is straight-forward although you do have to account for the condition when the inventory does not meet the order amount.&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;Column = 
    VAR __ItemCode = [ItemCode]
    VAR __QtyOrd = [QtyOrd]
    VAR __Separator = ","
    VAR __SearchText = CONCATENATEX(FILTER('Inventory','Inventory'[ItemCode] = __ItemCode),[Location],",",[QtyStr],DESC)
    VAR __Len = LEN(__SearchText)
    VAR __Count = __Len - LEN(SUBSTITUTE(__SearchText,__Separator,"")) + 1
    VAR __Table = 
        ADDCOLUMNS(
            ADDCOLUMNS(
                GENERATESERIES(1,__Count,1),
                "__Word",
                    VAR __Text = SUBSTITUTE(__SearchText,__Separator,"|",IF([Value]=1,1,[Value]-1))
                    VAR __Start =
                        SWITCH(TRUE(),
                            __Count = 1,1,
                            [Value] = 1,1,
                            FIND("|",__Text)+1
                        )
                    VAR __End = 
                        SWITCH(TRUE(),
                            __Count = 1,__Len,
                            [Value] = 1,FIND("|",__Text) - 1,
                            [Value] = __Count,__Len,
                            FIND(__Separator,__Text,__Start)-1
                        )
                    VAR __Word = MID(__Text,__Start,__End - __Start + 1)
                RETURN __Word
            ),
            "__QtyStr",MAXX(FILTER('Inventory',[Location] = [__Word] &amp;amp;&amp;amp; [ItemCode] = __ItemCode),[QtyStr])
        )
    VAR __Table1 = 
        ADDCOLUMNS(
            ADDCOLUMNS(
                __Table,
                "__RunningTotal",SUMX(FILTER(__Table,[Value]&amp;lt;=EARLIER([Value])),[__QtyStr])
            ),
            "__Decrement",[__RunningTotal] - __QtyOrd)
    VAR __Index = MINX(FILTER(__Table1,[__Decrement]&amp;gt;=0),[Value])
    VAR __Locations = COUNTROWS(FILTER(__Table1,[Value] &amp;lt;= __Index)) 
RETURN
    IF(ISBLANK(__Locations),COUNTROWS(DISTINCT('Inventory'[Location])),__Locations)&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;LI-CODE lang="markup"&gt;Column 2 = 
    VAR __ItemCode = [ItemCode]
    VAR __QtyOrd = [QtyOrd]
    VAR __Separator = ","
    VAR __SearchText = CONCATENATEX(FILTER('Inventory','Inventory'[ItemCode] = __ItemCode),[Location],",",[QtyStr],DESC)
    VAR __Len = LEN(__SearchText)
    VAR __Count = __Len - LEN(SUBSTITUTE(__SearchText,__Separator,"")) + 1
    VAR __Table = 
        ADDCOLUMNS(
            ADDCOLUMNS(
                GENERATESERIES(1,__Count,1),
                "__Word",
                    VAR __Text = SUBSTITUTE(__SearchText,__Separator,"|",IF([Value]=1,1,[Value]-1))
                    VAR __Start =
                        SWITCH(TRUE(),
                            __Count = 1,1,
                            [Value] = 1,1,
                            FIND("|",__Text)+1
                        )
                    VAR __End = 
                        SWITCH(TRUE(),
                            __Count = 1,__Len,
                            [Value] = 1,FIND("|",__Text) - 1,
                            [Value] = __Count,__Len,
                            FIND(__Separator,__Text,__Start)-1
                        )
                    VAR __Word = MID(__Text,__Start,__End - __Start + 1)
                RETURN __Word
            ),
            "__QtyStr",MAXX(FILTER('Inventory',[Location] = [__Word] &amp;amp;&amp;amp; [ItemCode] = __ItemCode),[QtyStr])
        )
    VAR __Table1 = 
        ADDCOLUMNS(
            ADDCOLUMNS(
                __Table,
                "__RunningTotal",SUMX(FILTER(__Table,[Value]&amp;lt;=EARLIER([Value])),[__QtyStr])
            ),
            "__Decrement",[__RunningTotal] - __QtyOrd)
    VAR __Index = MINX(FILTER(__Table1,[__Decrement]&amp;gt;=0),[Value])
    VAR __Locations = FILTER(__Table1,[Value] &amp;lt;= __Index)
    VAR __Text1 = CONCATENATEX(__Table1,[__Word],",",[__QtyStr],DESC)
    VAR __Text = CONCATENATEX(__Locations,[__Word],",",[__QtyStr],DESC)
RETURN
    IF(ISBLANK(__Text),__Text1,__Text)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Aug 2021 16:38:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2044441#M45921</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-08-29T16:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2044679#M45929</link>
      <description>&lt;P&gt;Here's a file with a full solution that can be adjusted to your heart's content. It should be faster than&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;'s formulas and is much more customizable. Not to mention it's infinitely easier to understand &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; without any flimsy string manipulation. Just download and watch the beauty of the solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://1drv.ms/u/s!ApyQEauTSLtOgZlOIZRShgVXkPOZnw?e=pVzdFb" target="_blank"&gt;https://1drv.ms/u/s!ApyQEauTSLtOgZlOIZRShgVXkPOZnw?e=pVzdFb&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Enjoy!&lt;/P&gt;</description>
      <pubDate>Sun, 29 Aug 2021 23:03:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2044679#M45929</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-08-29T23:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2044684#M45930</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="255913" data-lia-user-login="daxer-almighty" class="lia-mention lia-mention-user"&gt;daxer-almighty&lt;/a&gt;&amp;nbsp;Well, you used a calculated table even though you hid it, it is still there. Not sure how you would prove performance or fragility one way or another. But, it's essentially using exactly the same technique as mine using GENERATESERIES, CONCATENATEX, etc., etc. Fundamentally it is no different except you incorporate your table in the model versus mine is in a VAR. Which, if we were to get into a debate about which one took up more space in the model...&lt;/P&gt;</description>
      <pubDate>Sun, 29 Aug 2021 23:19:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2044684#M45930</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-08-29T23:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045006#M45937</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;Hi Greg, how to modify above if we take the case that the items are not replenished quickly and use the fulfilment criteria in which the sales order arrive (S1 first andthen S2...so on ascending order)in the warehouse? example- S1 is using stock of A1 from L1 and L2 and only 2 is left in L1&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 04:29:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045006#M45937</guid>
      <dc:creator>learner03</dc:creator>
      <dc:date>2021-08-30T04:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045801#M45946</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes. I did use a calc table but I don't have any remorse &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Such a table should be, of course, created in PQ or in the source (you know the story). But I didn't have time (was too tired, it was deep into the night) to move this logic into PQ. But it's totally doable in there and is the right thing to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Second, DAX that has to operate on strings and does a lot of mangling-jumbling on them &lt;STRONG&gt;is fragile by definition&lt;/STRONG&gt;. It's really for a reason that RMDB's store data in atomic portions, or at least they should if the person who builds them has any idea about a well-designed system. Here you've got the same story. After all, a tabular cube &lt;STRONG&gt;IS&lt;/STRONG&gt; a database, albeit tabular (which does not change a single bit).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Third, where the heck did you see GENERATESERIES in my solution? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; My code has no mention of it. On top of that, my code is infnitely more readable than yours, which also means it's more maintainable, customizable and user-friendly. This, of course, counts just as it counts in Python. And productivity counts, too. Just as it does in Python. It is for a reason that Python with its "strange" and strict formatting rules has become the most widely used language in the world in just too many fields to mention.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fourth, I'm not sure about the space requirements. Maybe it does play a role, maybe it does not. But as long I don't have to save on storage/RAM, I always choose a model that is easier to maintain, understand and more flexible. It's exactly the same as it is for any programming task: First, make it correct, then make it fast, then (maybe) think about space... But time comes first these days and you know it. Also the ease with which people can grasp the code and make changes to it is of paramount importance. One should never lose readability/clarity of code from sight. Never. This is actually what distinguishes an excellent programmer from a programmer. "Any fool can write code that a machine can understand. It takes a good programmer to write code that people can understand." Rings a bell? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; It should.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the person who got the solution says later that it takes too much space in RAM (highly improbable but possible), well, then I'll try to think about a different solution. You also know the saying: "Premature optimization is the root of all evil." (&lt;SPAN&gt;quote by&amp;nbsp;Sir&amp;nbsp;&lt;/SPAN&gt;Tony Hoare&lt;STRONG&gt;,&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;popularized by Donald Knuth).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;One last thing... It generally is much better (and advisable) to sacrifice memory for faster, more maintainable, more readable code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I took a look at this UGLINESS:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;VAR __SearchText = CONCATENATEX(FILTER('Inventory','Inventory'[ItemCode] = __ItemCode),[Location],",",[QtyStr],DESC)
    VAR __Len = LEN(__SearchText)
    VAR __Count = __Len - LEN(SUBSTITUTE(__SearchText,__Separator,"")) + 1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I knew immediately it was not the correct approach. The code above is &lt;STRONG&gt;plain ugly&lt;/STRONG&gt;. This is the first thing that comes to my mind when I (try to) read it and understand.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 10:00:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045801#M45946</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-08-30T10:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045819#M45948</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="305193" data-lia-user-login="learner03" class="lia-mention lia-mention-user"&gt;learner03&lt;/a&gt;&amp;nbsp;Yeah, I had a feeling that question was coming at some point and have been going back and forth on whether it starts to fall down the DAX recursion rabbit hole. Let me take a look.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 09:59:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045819#M45948</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-08-30T09:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045826#M45950</link>
      <description>&lt;P&gt;Well, Greg, it looks like PQ enters the stage &lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 10:02:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045826#M45950</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-08-30T10:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045911#M45952</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="255913" data-lia-user-login="daxer-almighty" class="lia-mention lia-mention-user"&gt;daxer-almighty&lt;/a&gt;&amp;nbsp;You missed the boundary case where there is not enough inventory to fulfill the order, your solution returns blank versus the correct answer of all locations.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 10:30:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045911#M45952</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-08-30T10:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045928#M45954</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="255913" data-lia-user-login="daxer-almighty" class="lia-mention lia-mention-user"&gt;daxer-almighty&lt;/a&gt;&amp;nbsp;You missed the boundary case where there is not enough inventory to fulfill the order, your solution returns blank versus the correct answer of all locations.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;, are you 100% sure? First, it would be highly inconsistent to do that since the number of locations would be 0 and the string would contain all of them... Not the greatest of designs, is it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, I've checked the original post:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"Now I want calculate --&amp;gt; For each sales order, for each item in that order, how many locations are required to fulfill that item requirement in that order. The locations with highest quantity should be checked first. So want to have a calculated column in&amp;nbsp;&lt;STRONG&gt;SalesOrder&amp;nbsp;&lt;/STRONG&gt;where each row has the number of rows from&amp;nbsp;&lt;STRONG&gt;Inventory&lt;/STRONG&gt;&amp;nbsp;to sum up the&amp;nbsp;&lt;STRONG&gt;QtyOrd&amp;nbsp;&lt;/STRONG&gt;value(starting from the location with highest quantity).&amp;nbsp;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Also, I want another column with location names which will fulfll that item order.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;I hope I have explained my question clearly."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Where does it imply what you claim?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It says "How many locations are required to fulfill that item..." Returning 0 means "there is no number of locations that would". And since there aren't any, it just stands to reason that the string be empty/BLANK.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 10:37:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045928#M45954</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-08-30T10:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045942#M45956</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="255913" data-lia-user-login="daxer-almighty" class="lia-mention lia-mention-user"&gt;daxer-almighty&lt;/a&gt;&amp;nbsp;If you checked my solution, my solution returns 3 for the location count and all the locations.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 10:41:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045942#M45956</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-08-30T10:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045957#M45959</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please... mate. I don't exactly follow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You're accusing my code of not adhering to what your code does? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Where did you get the rule from that stipulates that the lines which can't be fulfilled by any number of locations must be paired with all locations and the number must be 3 (the number of all eligible locations)? For the time being I can see that it's a rule you've invented yourself for some strange reason.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This rule of yours has 2 issues:&lt;/P&gt;&lt;P&gt;1. It makes the design inconsistent. How, without making calculations, can you distinguish between lines that CAN be fulfilled by all locations only and the ones that can't be fulfilled by any number of locations?&lt;/P&gt;&lt;P&gt;2. This rule does not exist in the original specification.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 10:49:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045957#M45959</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-08-30T10:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045964#M45961</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="255913" data-lia-user-login="daxer-almighty" class="lia-mention lia-mention-user"&gt;daxer-almighty&lt;/a&gt;&amp;nbsp;Incorrect yet again I am afraid. No need for PQ.&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="305193" data-lia-user-login="learner03" class="lia-mention lia-mention-user"&gt;learner03&lt;/a&gt;&amp;nbsp;the following lists the number of locations taking into account a FIFO procedure for the sales orders. It is a minor tweak of the original solution. In this case, if you run out of locations capable of fulfilling the orders then it returns 0 locations capable of fullfilling the complete order. Could be tweaked for partial order fulfillment.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column 3 = 
    VAR __ItemCode = [ItemCode]
    VAR __Order = [Index]
    VAR __QtyOrd = SUMX(FILTER('SalesOrders',[Index]&amp;lt;=__Order &amp;amp;&amp;amp; [ItemCode]=__ItemCode),[QtyOrd])
    VAR __Separator = ","
    VAR __SearchText = CONCATENATEX(FILTER('Inventory','Inventory'[ItemCode] = __ItemCode),[Location],",",[QtyStr],DESC)
    VAR __Len = LEN(__SearchText)
    VAR __Count = __Len - LEN(SUBSTITUTE(__SearchText,__Separator,"")) + 1
    VAR __Table = 
        ADDCOLUMNS(
            ADDCOLUMNS(
                GENERATESERIES(1,__Count,1),
                "__Word",
                    VAR __Text = SUBSTITUTE(__SearchText,__Separator,"|",IF([Value]=1,1,[Value]-1))
                    VAR __Start =
                        SWITCH(TRUE(),
                            __Count = 1,1,
                            [Value] = 1,1,
                            FIND("|",__Text)+1
                        )
                    VAR __End = 
                        SWITCH(TRUE(),
                            __Count = 1,__Len,
                            [Value] = 1,FIND("|",__Text) - 1,
                            [Value] = __Count,__Len,
                            FIND(__Separator,__Text,__Start)-1
                        )
                    VAR __Word = MID(__Text,__Start,__End - __Start + 1)
                RETURN __Word
            ),
            "__QtyStr",MAXX(FILTER('Inventory',[Location] = [__Word] &amp;amp;&amp;amp; [ItemCode] = __ItemCode),[QtyStr])
        )
    VAR __Table1 = 
        ADDCOLUMNS(
            ADDCOLUMNS(
                __Table,
                "__RunningTotal",SUMX(FILTER(__Table,[Value]&amp;lt;=EARLIER([Value])),[__QtyStr])
            ),
            "__Decrement",[__RunningTotal] - __QtyOrd)
    VAR __Index = MINX(FILTER(__Table1,[__Decrement]&amp;gt;=0),[Value])
    VAR __Locations = COUNTROWS(FILTER(__Table1,[Value] &amp;lt;= __Index)) 
RETURN
    __Locations+0&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 30 Aug 2021 10:56:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045964#M45961</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-08-30T10:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045980#M45963</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="255913" data-lia-user-login="daxer-almighty" class="lia-mention lia-mention-user"&gt;daxer-almighty&lt;/a&gt;&amp;nbsp;Granted, it's a business decision and could be open to interpretation given the original ground rules, all locations would be required to fulfill that order. Sure, additional inventory would be required but, sticking to the letter of the law and not making assumptions, the original ground rules would be that all locations should be returned.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 11:01:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045980#M45963</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-08-30T11:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045982#M45964</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand that now you've acknowledged, albeit indirectly (sadly), that the specification did not say a single word about returning all locations (and 3 - &lt;EM&gt;[EDT: it was 0 here orginally but, of course, it was a mistake]&lt;/EM&gt;) when no number of locations could fulfill the requirement. That's good in any case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to ask you a question. Do you consider the code you've written beautiful and readable to a person that comes to this problem the very first time? On a scale from 1 (ugly like hell) to 5 (beautiful), which score would you assign to your code? But honestly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 11:15:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2045982#M45964</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-08-30T11:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2046013#M45965</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="255913" data-lia-user-login="daxer-almighty" class="lia-mention lia-mention-user"&gt;daxer-almighty&lt;/a&gt;&amp;nbsp;Ah but beauty is in the eye of the beholder. I consider the code well formatted, progressing in a logical thought process and broken into debuggable chunks of code. Above all, I consider the code to return the correct answer and be flexible enough to handle changing requirements like FIFO, LIFO, etc. with relative ease. It is a small thing once a solution has been found to improve upon that solution. The hard thing is finding the solution in the first place. And often finding a solution requires cracking some eggs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you are so fond of Nietzsche&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;"I want to learn more and more to see as beautiful what is necessary in things; then I shall be one of those who make things beautiful.&amp;nbsp;Amor fati: let that be my love henceforth! I do not want to wage war against what is ugly. I do not want to accuse; I do not even want to accuse those who accuse.&amp;nbsp;Looking away&amp;nbsp;shall be my only negation."&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 11:15:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2046013#M45965</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-08-30T11:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2046021#M45968</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="305193" data-lia-user-login="learner03" class="lia-mention lia-mention-user"&gt;learner03&lt;/a&gt;,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="314899" data-lia-user-login="manuvats" class="lia-mention lia-mention-user"&gt;manuvats&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Guys, I would really like to know if the code that&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;has given you will ever return on a real model. My suspicion is that it'll last for quite a time on a decent model. Might not even return. Seen such things in the past with calculated columns on big fact tables. Have even troubleshot such isuses here on this forum.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please run this code on a real model with a SalesOrder table that has hundreds of millions of rows or whatever you've got (but make it real). Let's see whether I'm right or wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 11:31:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2046021#M45968</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-08-30T11:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of top rows with sum of their values equal to a particular dynamic value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2046025#M45969</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="255913" data-lia-user-login="daxer-almighty" class="lia-mention lia-mention-user"&gt;daxer-almighty&lt;/a&gt;&amp;nbsp;Granted, it's a business decision and could be open to interpretation given the original ground rules, all locations would be required to fulfill that order. Sure, additional inventory would be required but, sticking to the letter of the law and not making assumptions, the original ground rules would be that all locations should be returned.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;It would be a very stupid business decision to return all locations and their number for lines that can't be fulfilled by any number of locations... Honestly, I wouldn't like to work for such a business &lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 11:24:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-number-of-top-rows-with-sum-of-their-values-equal-to-a/m-p/2046025#M45969</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-08-30T11:24:56Z</dc:date>
    </item>
  </channel>
</rss>

