<?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 Fetch last non-blank value for any date with multiple filters in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Fetch-last-non-blank-value-for-any-date-with-multiple-filters/m-p/3980866#M154363</link>
    <description>&lt;P&gt;I am trying to produce the sum of a running total for all SKU's selected by slicers on any selected date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table with transaction data as follows:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Warehouse&amp;nbsp; |&lt;/TD&gt;&lt;TD&gt;SKU |&lt;/TD&gt;&lt;TD&gt;TxDate |&lt;/TD&gt;&lt;TD&gt;DayQty |&lt;/TD&gt;&lt;TD&gt;RT (Running Total)&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This measure works for each SKU individually:&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="javascript"&gt;RT by Size = 
VAR d = 
    SELECTEDVALUE('Date'[Date])
RETURN
    CALCULATE(
        LASTNONBLANKVALUE(StkDayQty[TxDate], SUM(StkDayQty[RT])),
        StkDayQty[TxDate] &amp;lt;= d,
        CROSSFILTER('Date'[Date], StkDayQty[TxDate], none)
    )&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;I created a table that assigns a unique ID (IdWhseStk) for each SKU in each warehouse and attempted to create a measure that will sum RT for all selected by slicers:&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="javascript"&gt;RT Total = SUMX(
    VALUES(WhseStk[IdWhseStk]),
    [RT by Size])&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;This does not work:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Also tried this with the same result:&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="javascript"&gt;RT Selected = 
VAR _RTSize = [RT by Size]

RETURN
if( isfiltered(WhseStk[IdWhseStk]) ,
SUMX (
VALUES ( WhseStk[IdWhseStk] ),_RTSize))&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;I even tried to merge the entire date table to each SKU before calculating the RT in Power Query so that I have a distinct RT for every SKU on every date but it results in millions of rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't find a solution that I can apply to my dataset. Any advice would be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Jun 2024 23:22:35 GMT</pubDate>
    <dc:creator>Revolution</dc:creator>
    <dc:date>2024-06-07T23:22:35Z</dc:date>
    <item>
      <title>Fetch last non-blank value for any date with multiple filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Fetch-last-non-blank-value-for-any-date-with-multiple-filters/m-p/3980866#M154363</link>
      <description>&lt;P&gt;I am trying to produce the sum of a running total for all SKU's selected by slicers on any selected date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table with transaction data as follows:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Warehouse&amp;nbsp; |&lt;/TD&gt;&lt;TD&gt;SKU |&lt;/TD&gt;&lt;TD&gt;TxDate |&lt;/TD&gt;&lt;TD&gt;DayQty |&lt;/TD&gt;&lt;TD&gt;RT (Running Total)&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This measure works for each SKU individually:&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="javascript"&gt;RT by Size = 
VAR d = 
    SELECTEDVALUE('Date'[Date])
RETURN
    CALCULATE(
        LASTNONBLANKVALUE(StkDayQty[TxDate], SUM(StkDayQty[RT])),
        StkDayQty[TxDate] &amp;lt;= d,
        CROSSFILTER('Date'[Date], StkDayQty[TxDate], none)
    )&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;I created a table that assigns a unique ID (IdWhseStk) for each SKU in each warehouse and attempted to create a measure that will sum RT for all selected by slicers:&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="javascript"&gt;RT Total = SUMX(
    VALUES(WhseStk[IdWhseStk]),
    [RT by Size])&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;This does not work:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Also tried this with the same result:&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="javascript"&gt;RT Selected = 
VAR _RTSize = [RT by Size]

RETURN
if( isfiltered(WhseStk[IdWhseStk]) ,
SUMX (
VALUES ( WhseStk[IdWhseStk] ),_RTSize))&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;I even tried to merge the entire date table to each SKU before calculating the RT in Power Query so that I have a distinct RT for every SKU on every date but it results in millions of rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't find a solution that I can apply to my dataset. Any advice would be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2024 23:22:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Fetch-last-non-blank-value-for-any-date-with-multiple-filters/m-p/3980866#M154363</guid>
      <dc:creator>Revolution</dc:creator>
      <dc:date>2024-06-07T23:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch last non-blank value for any date with multiple filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Fetch-last-non-blank-value-for-any-date-with-multiple-filters/m-p/3981342#M154384</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="702964" data-lia-user-login="Revolution" class="lia-mention lia-mention-user"&gt;Revolution&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;It's better if you provide Some sample data&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2024 14:41:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Fetch-last-non-blank-value-for-any-date-with-multiple-filters/m-p/3981342#M154384</guid>
      <dc:creator>Dangar332</dc:creator>
      <dc:date>2024-06-08T14:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch last non-blank value for any date with multiple filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Fetch-last-non-blank-value-for-any-date-with-multiple-filters/m-p/3983766#M154457</link>
      <description>&lt;P&gt;From what I understand of the above, this might be a visual calculation case. I took the canonical Contoso sales data and calcualuated the profit as calculated column in the visual (Just to show that a calculated column in the visual works)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;In my data there is a product key and date key that play the roles of your field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then you can use the running sum as another calculated column in the visual:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RunningSum =&lt;/SPAN&gt; &lt;SPAN&gt;RUNNINGSUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Profit]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;Then I selected a few date keys with a slicer and did another date slicer with "before date" settings&lt;/P&gt;&lt;P&gt;You can see that this produces indeed the running totals acrosss the product keys&lt;/P&gt;&lt;img /&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;The approach definetely reduces filter context complexity. It is a matter of taste.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 10 Jun 2024 13:53:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Fetch-last-non-blank-value-for-any-date-with-multiple-filters/m-p/3983766#M154457</guid>
      <dc:creator>scee07</dc:creator>
      <dc:date>2024-06-10T13:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch last non-blank value for any date with multiple filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Fetch-last-non-blank-value-for-any-date-with-multiple-filters/m-p/3984212#M154469</link>
      <description>&lt;P&gt;Not sure you need a helper table. I assume your main issue is that your date slicer is filtering the&amp;nbsp;VALUES ( WhseStk[IdWhseStk] ) that you are iterating over. Try:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;RT Total = 
SUMX(
    CALCULATETABLE( VALUES(StkDayQty[SKU]), REMOVEFILTERS( 'Date' ) ),
    [RT by Size]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2024 17:34:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Fetch-last-non-blank-value-for-any-date-with-multiple-filters/m-p/3984212#M154469</guid>
      <dc:creator>MarkLaf</dc:creator>
      <dc:date>2024-06-10T17:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch last non-blank value for any date with multiple filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Fetch-last-non-blank-value-for-any-date-with-multiple-filters/m-p/3990935#M154787</link>
      <description>&lt;P&gt;This doesn't work because I have the same SKU for different warehouses. Hence the helper table which was created in SQL at the source. I discovered duplicates so made a new table containing unique IDs for each SKU+Warehouse. I now have it working.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 11:07:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Fetch-last-non-blank-value-for-any-date-with-multiple-filters/m-p/3990935#M154787</guid>
      <dc:creator>Revolution</dc:creator>
      <dc:date>2024-06-13T11:07:41Z</dc:date>
    </item>
  </channel>
</rss>

