<?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: Calculated table filter by N days in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2205968#M51911</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="97916" data-lia-user-login="Cbutler" class="lia-mention lia-mention-user"&gt;Cbutler&lt;/a&gt;&amp;nbsp;Yeah, so if you use that as an actual table, it will not be dynamic but only caculated at load time. You will have to put it as a VAR within your other measures to make it truly dynamic. It's such a pain that measures cannot return tables. That would make things sooooo much simpler and better.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Nov 2021 14:03:29 GMT</pubDate>
    <dc:creator>Greg_Deckler</dc:creator>
    <dc:date>2021-11-24T14:03:29Z</dc:date>
    <item>
      <title>Calculated table filter by N days</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2205721#M51892</link>
      <description>&lt;P&gt;Help!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am trying to create a calculated table that filters by a dynamic date to pull back the results for the last n or 10 days.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;So I need a calculated table that is written to show the MAX date (which is (today) off another calc table), then it should track back should the date filter change. But I can't seem to work out how to filter as a calculated table for the MAX date -10?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can anyone help?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 11:59:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2205721#M51892</guid>
      <dc:creator>Cbutler</dc:creator>
      <dc:date>2021-11-24T11:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated table filter by N days</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2205760#M51894</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="97916" data-lia-user-login="Cbutler" class="lia-mention lia-mention-user"&gt;Cbutler&lt;/a&gt;&amp;nbsp;can you try this&lt;/P&gt;
&lt;P&gt;Filter (tbl1, tbl1[date]=calculate(max(tbl2[date]),all(tbl2)))&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 12:13:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2205760#M51894</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2021-11-24T12:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated table filter by N days</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2205776#M51896</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="24978" data-lia-user-login="smpa01" class="lia-mention lia-mention-user"&gt;smpa01&lt;/a&gt;&amp;nbsp;Thanks for replying..... Where do I add in the -10 days?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Its bringing back all the days still... I just need the last -10 days from the as at date filter&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is how I have done it in the measure that works, but I need the table version for other calcs&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&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;&amp;nbsp;any ideas? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 12:45:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2205776#M51896</guid>
      <dc:creator>Cbutler</dc:creator>
      <dc:date>2021-11-24T12:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated table filter by N days</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2205826#M51900</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="97916" data-lia-user-login="Cbutler" class="lia-mention lia-mention-user"&gt;Cbutler&lt;/a&gt;&amp;nbsp;If you are trying to create a new table, maybe use CALCULATETABLE? Not sure I'm fully in sync with what you are trying to do. But something like:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Table = 
  VAR Last_Date = MAX('Date'[Date])
RETURN
  CALCULATETABLE('Table',FILTER(ALL('Date'[Date]),'Date'[Date]&amp;gt;Last_Date - 10 &amp;amp;&amp;amp; 'Date'[Date]&amp;lt;=Last_Date))&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 24 Nov 2021 12:45:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2205826#M51900</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-11-24T12:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated table filter by N days</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2205869#M51906</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;oh thats got me closer, but the as at date is not changing the table filter.&amp;nbsp;&lt;BR /&gt;Its filtering from MAX table date (today) -10 so pulling data form 15-24th (no data in there for today), but when I change my filter as below...I need the table to recalculte the -10 days, so selecting 15/10/21 would filter the table to show 6/10/21 to 15/10/21...&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 13:06:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2205869#M51906</guid>
      <dc:creator>Cbutler</dc:creator>
      <dc:date>2021-11-24T13:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated table filter by N days</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2205968#M51911</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="97916" data-lia-user-login="Cbutler" class="lia-mention lia-mention-user"&gt;Cbutler&lt;/a&gt;&amp;nbsp;Yeah, so if you use that as an actual table, it will not be dynamic but only caculated at load time. You will have to put it as a VAR within your other measures to make it truly dynamic. It's such a pain that measures cannot return tables. That would make things sooooo much simpler and better.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 14:03:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2205968#M51911</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-11-24T14:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated table filter by N days</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2211357#M52183</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="97916" data-lia-user-login="Cbutler" class="lia-mention lia-mention-user"&gt;Cbutler&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The table in the Data&lt;img /&gt;can not be a&amp;nbsp;&lt;SPAN&gt;dynamic table unless you use power query editor.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;But in visual table ok.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In visual table, you can create a measure like the following to show the last n days.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;IF in N days =
VAR _Nday =
    SELECTEDVALUE( 'N days Parameter'[N days Parameter] )
VAR _StartDate =
    TODAY() - _Nday
RETURN
    IF(
        SELECTEDVALUE( 'Table'[Date] ) &amp;gt;= _StartDate
            &amp;amp;&amp;amp; SELECTEDVALUE( 'Table'[Date] ) &amp;lt;= TODAY(),
        1,
        0
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before this , you should&amp;nbsp;create a parameter named N days Parameter&amp;nbsp;via what if new parameter&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Then, put the measure IF in N days into the filters on this visual and set item is 1 as the screenshot:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And i put my example&amp;nbsp;pbix file in the end you can refer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Community Support Team _ chenwu zhu&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 06:45:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2211357#M52183</guid>
      <dc:creator>v-chenwuz-msft</dc:creator>
      <dc:date>2021-11-29T06:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated table filter by N days</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2226349#M53013</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="320777" data-lia-user-login="v-chenwuz-msft" class="lia-mention lia-mention-user"&gt;v-chenwuz-msft&lt;/a&gt;&amp;nbsp;, thanks for this, unfortunatey I do not wish the number of days to be dynamic, but the MAX date must be dynamic to change what is pulled in to the calculated table.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;eg. Max date is "today", so my table shows 07/12/21 and the 10 days before (data in table is 27/11/2021 to 07/12/21) however I want to view data "as at" 11/11/21, so I want to use a slicer to change the MAX date to 11/11/21 so the data in the calculated table shows data from 01/11/21 to 11/11/21.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Hope that makes sense. I have a work around with measures, but this makes the report perfrmance very poor! and when I tried to load it earlier was getting a memory error and the visuals could not display &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;If I can not find a solution I will just have to have it as a fixed "today" date and not allow users to look back at the historical data.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 20:45:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2226349#M53013</guid>
      <dc:creator>Cbutler</dc:creator>
      <dc:date>2021-12-07T20:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated table filter by N days</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2227265#M53070</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="97916" data-lia-user-login="Cbutler" class="lia-mention lia-mention-user"&gt;Cbutler&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I probably understand what you mean. Select a day, and the selected day is the maximum date within ten days. What needs to be displayed is the data for these ten days.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before creating a measure, first create a table through the following code to achieve.&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;Max date for slicer = CALENDAR(MIN('Table'[Date]),TODAY())&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the code for measure:&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;IF in N days =
VAR _Nday = 10
VAR _EndDate =
    IF(
        SELECTEDVALUE( 'Max date for slicer'[Date] ) = BLANK(),
        TODAY(),
        SELECTEDVALUE( 'Max date for slicer'[Date] )
    )
VAR _StartDate = _EndDate - _Nday
RETURN
    IF(
        SELECTEDVALUE( 'Table'[Date] ) &amp;gt;= _StartDate
            &amp;amp;&amp;amp; SELECTEDVALUE( 'Table'[Date] ) &amp;lt;= _EndDate,
        1,
        0
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Drag measure into Filters on this visula and set it show items is 1. Create a slicer for user to select the MAX date. the values of slicer come from new table 'Max date for slicer'.&amp;nbsp;Rest assured, this 'Max date for slicer' will change with the refresh of the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Community Support Team _ chenwu zhu&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 08:56:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-filter-by-N-days/m-p/2227265#M53070</guid>
      <dc:creator>v-chenwuz-msft</dc:creator>
      <dc:date>2021-12-08T08:56:06Z</dc:date>
    </item>
  </channel>
</rss>

