<?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: Sum interval considering many filters in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-interval-considering-many-filters/m-p/4395475#M174511</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="911636" data-lia-user-login="ClaudioF" class="lia-mention lia-mention-user"&gt;ClaudioF&lt;/a&gt;&amp;nbsp;, Try using&lt;/P&gt;
&lt;P&gt;dax&lt;BR /&gt;Measure =&lt;BR /&gt;VAR _date = CALCULATE(MAX('Table date'[date]), ALLSELECTED('Table date'))&lt;BR /&gt;VAR _item = MAX('Table orders'[Item])&lt;BR /&gt;VAR _orders = &lt;BR /&gt;FILTER(&lt;BR /&gt;ALLSELECTED('Table orders'),&lt;BR /&gt;[Item] = _item &amp;amp;&amp;amp;&lt;BR /&gt;[date] &amp;lt;= _date&lt;BR /&gt;)&lt;BR /&gt;VAR _stock = &lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM('Table stock'[quantity]),&lt;BR /&gt;FILTER(&lt;BR /&gt;ALL('Table stock'),&lt;BR /&gt;[item] = _item&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;VAR _runningTotal = &lt;BR /&gt;SUMX(&lt;BR /&gt;FILTER(&lt;BR /&gt;_orders,&lt;BR /&gt;[Order num] &amp;lt;= EARLIER('Table orders'[Order num])&lt;BR /&gt;),&lt;BR /&gt;[quantity]&lt;BR /&gt;)&lt;BR /&gt;VAR _result = IF(_runningTotal &amp;lt;= _stock, "available", "out")&lt;BR /&gt;RETURN&lt;BR /&gt;IF(ISBLANK(_runningTotal), BLANK(), _result)&lt;/P&gt;</description>
    <pubDate>Wed, 05 Feb 2025 05:16:25 GMT</pubDate>
    <dc:creator>bhanu_gautam</dc:creator>
    <dc:date>2025-02-05T05:16:25Z</dc:date>
    <item>
      <title>Sum interval considering many filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-interval-considering-many-filters/m-p/4395389#M174507</link>
      <description>&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been here a time ago to solve a problem within this same topic, the thing is, the solution was complete but i found out that one other thing was needed.&lt;/P&gt;&lt;P&gt;I need the following dax code, not to consider all the order as "out", when the sum of items reach the total of stok available, but, i need to test others orders to see if the amount of the stok can be used still, axample: i have orders 333, 444 and 555 with the item bbb, with quantities 2, 30 and 5, the stok is 10 for this item, the actual code, tests the stok to the orders and the result is : available, ou, out; but i need the result to be: available, out, available.. of course, following the same logic of the earlier order num, only inside of the range date i select. When i select the date 01/03/25 to 01/03/25, the only orders that have in this date are the in the example..&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Measure =&lt;BR /&gt;VAR _date = CALCULATE(MAX('Table date'[date]), ALLSELECTED('Table date'))&lt;BR /&gt;VAR _quantity =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM('Table orders'[quantity]),&lt;BR /&gt;FILTER(&lt;BR /&gt;ALLSELECTED('Table orders'),&lt;BR /&gt;[Item] = MAX('Table orders'[Item]) &amp;amp;&amp;amp;&lt;BR /&gt;[date] &amp;lt;= MAX('Table orders'[date]) &amp;amp;&amp;amp;&lt;BR /&gt;[Order num] &amp;lt;= MAX('Table orders'[Order num]) -- Considera o número do pedido&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;VAR _stock =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM('Table stock'[quantity]),&lt;BR /&gt;FILTER(&lt;BR /&gt;ALL('Table stock'),&lt;BR /&gt;[item] = MAX('Table orders'[Item])&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;VAR _result = IF(_quantity &amp;lt;= _stock, "available", "out")&lt;BR /&gt;RETURN&lt;BR /&gt;IF(ISBLANK(_quantity), BLANK(), _result)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thankyou a lot allready!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 03:42:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-interval-considering-many-filters/m-p/4395389#M174507</guid>
      <dc:creator>ClaudioF</dc:creator>
      <dc:date>2025-02-05T03:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sum interval considering many filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-interval-considering-many-filters/m-p/4395475#M174511</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="911636" data-lia-user-login="ClaudioF" class="lia-mention lia-mention-user"&gt;ClaudioF&lt;/a&gt;&amp;nbsp;, Try using&lt;/P&gt;
&lt;P&gt;dax&lt;BR /&gt;Measure =&lt;BR /&gt;VAR _date = CALCULATE(MAX('Table date'[date]), ALLSELECTED('Table date'))&lt;BR /&gt;VAR _item = MAX('Table orders'[Item])&lt;BR /&gt;VAR _orders = &lt;BR /&gt;FILTER(&lt;BR /&gt;ALLSELECTED('Table orders'),&lt;BR /&gt;[Item] = _item &amp;amp;&amp;amp;&lt;BR /&gt;[date] &amp;lt;= _date&lt;BR /&gt;)&lt;BR /&gt;VAR _stock = &lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM('Table stock'[quantity]),&lt;BR /&gt;FILTER(&lt;BR /&gt;ALL('Table stock'),&lt;BR /&gt;[item] = _item&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;VAR _runningTotal = &lt;BR /&gt;SUMX(&lt;BR /&gt;FILTER(&lt;BR /&gt;_orders,&lt;BR /&gt;[Order num] &amp;lt;= EARLIER('Table orders'[Order num])&lt;BR /&gt;),&lt;BR /&gt;[quantity]&lt;BR /&gt;)&lt;BR /&gt;VAR _result = IF(_runningTotal &amp;lt;= _stock, "available", "out")&lt;BR /&gt;RETURN&lt;BR /&gt;IF(ISBLANK(_runningTotal), BLANK(), _result)&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 05:16:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-interval-considering-many-filters/m-p/4395475#M174511</guid>
      <dc:creator>bhanu_gautam</dc:creator>
      <dc:date>2025-02-05T05:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: Sum interval considering many filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-interval-considering-many-filters/m-p/4396182#M174538</link>
      <description>&lt;P&gt;&lt;A href="https://app.powerbi.com/reportEmbed?reportId=4934aedb-3f6c-42ce-8ebc-7376d4af98ca&amp;amp;autoAuth=true&amp;amp;ctid=dee74457-d751-4011-a5c4-44560cf8b415" target="_blank"&gt;https://app.powerbi.com/reportEmbed?reportId=4934aedb-3f6c-42ce-8ebc-7376d4af98ca&amp;amp;autoAuth=true&amp;amp;ctid=dee74457-d751-4011-a5c4-44560cf8b415&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is the link to the dashboard, it didnt work using the code you provided;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 10:44:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-interval-considering-many-filters/m-p/4396182#M174538</guid>
      <dc:creator>ClaudioF</dc:creator>
      <dc:date>2025-02-05T10:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Sum interval considering many filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-interval-considering-many-filters/m-p/4396794#M174569</link>
      <description>&lt;P&gt;This is the result i get when select the range date 01/03/25 using the code i gave:&lt;/P&gt;&lt;P&gt;The needed result should be: available, available, out, available;&lt;/P&gt;&lt;P&gt;The stock of the item bbb is 10;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 16:42:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-interval-considering-many-filters/m-p/4396794#M174569</guid>
      <dc:creator>ClaudioF</dc:creator>
      <dc:date>2025-02-05T16:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Sum interval considering many filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-interval-considering-many-filters/m-p/4399766#M174686</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="911636" data-lia-user-login="ClaudioF" class="lia-mention lia-mention-user"&gt;ClaudioF&lt;/a&gt;&amp;nbsp;, hello&amp;nbsp;bhanu_gautam, thank you for your prompt reply!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To meet your requirments, we suggest you use the measure instead of the column(we could not use measure in slicer).&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Create the DateRange first, then add the measure to filter the visual:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;DateRange = 
VAR _maxdate= CALCULATE(MAX('Table date'[Date]),ALLSELECTED('Table date'[Date]))
VAR _mindate=CALCULATE(MIN('Table date'[Date]),ALLSELECTED('Table date'))
RETURN IF(MAX('Table orders'[Date])&amp;lt;=_maxdate&amp;amp;&amp;amp; MAX('Table orders'[Date])&amp;gt;=_mindate,1,0)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Additionally, use this measure to verify the stock status for each line item based on the order number:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ItemStatus = 
VAR CurrentItem = SELECTEDVALUE('Table orders'[Item]) 
VAR CurrentOrderNum = SELECTEDVALUE('Table orders'[Order num])  

VAR StockAvailable = 
    CALCULATE(
        SUM('Table stock'[Quantity]),
        FILTER('Table stock', 'Table stock'[Item] = CurrentItem)
    )

VAR RunningStock = 
    SUMX(
        FILTER(
            ALLSELECTED('Table orders'),
            'Table orders'[Order num] &amp;lt;= CurrentOrderNum &amp;amp;&amp;amp; 'Table orders'[Quantity]&amp;lt;=StockAvailable &amp;amp;&amp;amp;'Table orders'[Item]=CurrentItem
        ),
        'Table orders'[quantity]
    )

RETURN    
IF(
    RunningStock &amp;lt;= StockAvailable &amp;amp;&amp;amp; MAX('Table orders'[Quantity])&amp;lt;=StockAvailable,
    "available",
    "out"
)
&lt;/LI-CODE&gt;
&lt;P&gt;Result for your reference:&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;Best regards,&lt;/P&gt;
&lt;P&gt;Joyce&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 09:36:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-interval-considering-many-filters/m-p/4399766#M174686</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-02-07T09:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: Sum interval considering many filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-interval-considering-many-filters/m-p/4400428#M174699</link>
      <description>&lt;P&gt;wonderfull!,&lt;/P&gt;&lt;P&gt;its working just the way i need, its a little complex, i thought i would be able just to incude more things later onde, but, if its not much, how could i add a other filter of date? i mean, this one will filter a new column in the orders table which is the column of the max date of the order, then , i have the orders created from a range of time to other, and then, the dates that these orders might be finished. this delivery date, will impact in the calculation of the orders just like the creation date, the thing is, the delivery date is the last date to be filtered;&lt;/P&gt;&lt;P&gt;How could it be done?&lt;/P&gt;&lt;P&gt;Thankyou a lot allready for your help;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 16:54:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-interval-considering-many-filters/m-p/4400428#M174699</guid>
      <dc:creator>ClaudioF</dc:creator>
      <dc:date>2025-02-07T16:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: Sum interval considering many filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-interval-considering-many-filters/m-p/4401198#M174714</link>
      <description>&lt;P&gt;Its no longer an issue, i just gost the solution by adding a new table called "delivery table", i made the correct relation between this and the orders table, then i placed a new data segmentation visual on the dashboard and inserted the date of delivery. The result was just right!&lt;/P&gt;&lt;P&gt;Thankyou all!! a lot.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Feb 2025 22:52:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-interval-considering-many-filters/m-p/4401198#M174714</guid>
      <dc:creator>ClaudioF</dc:creator>
      <dc:date>2025-02-08T22:52:24Z</dc:date>
    </item>
  </channel>
</rss>

