<?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: Using a temporary table variable to simplify CALCULATE in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-temporary-table-variable-to-simplify-CALCULATE/m-p/2548953#M72073</link>
    <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Thank you, John. REMOVEFILTERS does the job.&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;This formula works:&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;W/Orders O/Due (Related Date No Tmp Table) = &lt;BR /&gt;VAR SelectedEoWeek = SELECTEDVALUE( DatesRelated[End of Week] ) --- Relevant week end date obtained from visual &lt;BR /&gt;RETURN &lt;BR /&gt;    CALCULATE( COUNTROWS( WorkOrders ), &lt;BR /&gt;        REMOVEFILTERS( DatesRelated ),&lt;BR /&gt;        FILTER( ALL( WorkOrders[Compliance Date], WorkOrders[Finish Date] ), &lt;BR /&gt;            ( &lt;BR /&gt;                WorkOrders[Finish Date] = BLANK() &amp;amp;&amp;amp;                      --- WO does not have a finish date (still open)&lt;BR /&gt;                WorkOrders[Compliance Date] &amp;lt;= SelectedEoWeek   --- SelectedEOWeek is after Compliance Date&lt;BR /&gt;            ) &lt;BR /&gt;            ||&lt;BR /&gt;            ( &lt;BR /&gt;                WorkOrders[Finish Date] &amp;lt;&amp;gt; BLANK() &amp;amp;&amp;amp;                          --- WO has a finish date (closed)&lt;BR /&gt;                WorkOrders[Compliance Date] &amp;lt;= SelectedEoWeek &amp;amp;&amp;amp;   --- SelectedEOWeek falls between Compliance Date...&lt;BR /&gt;                SelectedEoWeek &amp;lt; WorkOrders[Finish Date]                     --- ... and Finish Date &lt;BR /&gt;            ) &lt;BR /&gt;        )&lt;BR /&gt;    ) &lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;However, I don't understand the logic: I would have thought that REMOVEFILTERS( DatesRelated ) would be sufficient to clear filters created by the visual on the DatesRelated dimension, and therefore the WorkOrders fact table would not be filtered by any dates. However, when I replace&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;FILTER( ALL( WorkOrders[Compliance Date], WorkOrders[Finish Date] ),&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;with FILTER( WorkOrders , the dates context is imposed again. Why does one have to clear filters on both the dimension and fact table dates columns? What is the sequence of steps here, first apply REMOVEFILTERS and then FILTER, or first FILTER then REMOVEFILTERS?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;I have spent about three days on this, reading many articles including the following ones that deal with the same topic:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;A href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/Removefilters-not-working/m-p/1488132" target="_blank"&gt;https://community.powerbi.com/t5/DAX-Commands-and-Tips/Removefilters-not-working/m-p/1488132&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/RemoveFilters-is-not-working/m-p/2524570" target="_blank"&gt;https://community.powerbi.com/t5/DAX-Commands-and-Tips/RemoveFilters-is-not-working/m-p/2524570&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Desktop/Removefilters-not-working-with-Date-Hierarchy/m-p/2196968" target="_blank"&gt;https://community.powerbi.com/t5/Desktop/Removefilters-not-working-with-Date-Hierarchy/m-p/2196968&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.reddit.com/r/PowerBI/comments/pmbmh3/removefilter_does_not_remove_the_context_filter/" target="_blank"&gt;https://www.reddit.com/r/PowerBI/comments/pmbmh3/removefilter_does_not_remove_the_context_filter/&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://dax.guide/calculate/" target="_blank"&gt;https://dax.guide/calculate/&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.sqlbi.com/articles/order-of-evaluation-in-calculate-parameters/" target="_blank"&gt;https://www.sqlbi.com/articles/order-of-evaluation-in-calculate-parameters/&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;A description of what CALCULATE actually does in its black box would be very helpful.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 31 May 2022 04:27:26 GMT</pubDate>
    <dc:creator>fretief</dc:creator>
    <dc:date>2022-05-31T04:27:26Z</dc:date>
    <item>
      <title>Using a temporary table variable to simplify CALCULATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-temporary-table-variable-to-simplify-CALCULATE/m-p/2535610#M71248</link>
      <description>&lt;P&gt;My data model consists of the following two tables (stripped of columns not relevant to this post):&lt;/P&gt;&lt;P&gt;Dates:&amp;nbsp;[Date],&amp;nbsp;[End of Week]&amp;nbsp; &amp;nbsp;WorkOrders: [Compliance Date],&amp;nbsp;[Finish Date],&amp;nbsp;[Order Type]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The tables are related Dates[Date]&amp;nbsp;1:* &amp;gt; WorkOrders[Compliance Date]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to calculate the number of overdue work orders at the end of every week, which consists of:&lt;BR /&gt;1) work orders that are not yet finished ( [Finish Date] is BLANK ); plus&lt;BR /&gt;2) work orders that were finished after their [Compliance Date]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both the following formulas work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;W/Orders O/Due by EoWeek 1 =&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;--- Formula 1&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;VAR SelectedEoWeek = SELECTEDVALUE( Dates[End of Week] ) --- Relevant week end date obtained from visual &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;VAR ODueOrders =&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;FILTER( ALL( WorkOrders ),&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;(&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-120px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;WorkOrders[Finish Date] = BLANK() &amp;amp;&amp;amp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --- WO does not have a finish date&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;WorkOrders[Compliance Date] &amp;lt;= SelectedEoWeek --- SelectedEoWeek is after Compliance Date&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;) &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;||&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;(&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-120px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;WorkOrders[Finish Date] &amp;lt;&amp;gt; BLANK() &amp;amp;&amp;amp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --- WO has a finish date&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;WorkOrders[Compliance Date] &amp;lt;= SelectedEoWeek &amp;amp;&amp;amp; --- SelectedEoWeek falls between Compliance Date...&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;SelectedEoWeek &amp;lt; WorkOrders[Finish Date]&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --- ... and Finish Date&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;)&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;RETURN COUNTROWS( ODueOrders )&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;W/Orders O/Due by EoWeek 2 =&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;--- Formula 2&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;VAR SelectedEoWeek = SELECTEDVALUE( Dates[End of Week] ) --- Relevant week end date obtained from visual &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;RETURN&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;CALCULATE( COUNTROWS( WorkOrders ),&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;FILTER( ALL( WorkOrders[Compliance Date], WorkOrders[Finish Date] ),&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-120px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;(&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-150px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;WorkOrders[Finish Date] = BLANK() &amp;amp;&amp;amp; --- WO does not have a finish date&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;WorkOrders[Compliance Date] &amp;lt;= SelectedEoWeek --- SelectedEoWeek is after Compliance Date&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-120px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;) &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;||&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;(&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-150px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;WorkOrders[Finish Date] &amp;lt;&amp;gt; BLANK() &amp;amp;&amp;amp; --- WO has a finish date&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;WorkOrders[Compliance Date] &amp;lt;= SelectedEoWeek &amp;amp;&amp;amp; --- SelectedEoWeek falls between Compliance Date...&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;SelectedEoWeek &amp;lt; WorkOrders[Finish Date] --- ... and Finish Date&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-120px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I prefer the format of Formula 1&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;VAR Temptable = FILTER( filterexp1 )&lt;BR /&gt;RETURN COUNTROWS( Temptable )&lt;/P&gt;&lt;P&gt;to the format of Formula 2&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;CALCULATE(&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;COUNTROWS ( Table ),&lt;BR /&gt;FILTER( filterexp2 )&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;)&lt;/P&gt;&lt;P&gt;because I can stick the FILTER( filterexp1 ) command for the Temptable into DAX Studio and debug my code whereas I have yet to find a way to visualise what DAX is committing behind the scenes in the case of the second format. The format of Formula 1 is also much more readable when, for instance DIVIDE( COUNTROWS(TempTableSubset), COUNTROWS(TempTable) ).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) The ALL( WorkOrders ) statement in Formula 1 clears all context filters, which means filters on WorkOrders[Order Type] are also cleared. The total number of overdue work orders is calculated correctly, but not the number of overdue orders by Order Type. How would one modify Formula 1 to only clear the context filter on the Compliance Date, but retain other context filters? I have tried various options but can't get the desired result. Almost all the documentation I find uses the format of Formula 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Assuming that one can develop a variation of Formula 1 that produces the same result as Formula 2, is there a reason (e.g. performance) why one formula is preferable over the other?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for taking the time to read &amp;amp; respond.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 08:58:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-temporary-table-variable-to-simplify-CALCULATE/m-p/2535610#M71248</guid>
      <dc:creator>fretief</dc:creator>
      <dc:date>2022-05-24T08:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using a temporary table variable to simplify CALCULATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-temporary-table-variable-to-simplify-CALCULATE/m-p/2535688#M71252</link>
      <description>&lt;P&gt;You could replace the ALL(WorkOrders) with ALLEXCEPT(WorkOrders,&amp;nbsp;&lt;SPAN&gt;WorkOrders[Order Type])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;As for whether 1 is preferable to the other, you would need to run server timings and query plan against both to make sure, but I would doubt that there is a significant performance difference between the 2.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 09:28:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-temporary-table-variable-to-simplify-CALCULATE/m-p/2535688#M71252</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2022-05-24T09:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using a temporary table variable to simplify CALCULATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-temporary-table-variable-to-simplify-CALCULATE/m-p/2538157#M71408</link>
      <description>&lt;P&gt;Thank you for your suggestion, John.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regarding Formula 1: Using &lt;SPAN&gt;ALLEXCEPT(WorkOrders,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;WorkOrders[Order Type]), would clear all filters except filters on [Order Type]. However, there are other filters on other columns that I also want to keep. What I am looking for is to keep all context filters that affect the WorkOrders table, except for the Date[End of Week] context, which propagates via the relationship to the WorkOrders[Compliance Date] column. Does one clear the filter context on the Date[End of Week] column (which is on the axis of the visual) or the WorkOrders[Compliance Date] column? How does one clear only the one context filter whilst retaining all the others? I looked at KEEPFILTERS but struggle to understand how it works.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Regarding Formula 2: I discovered that it retains the context filter passed from Dates[End of Week] via the relationship to WorkOrders[Compliance Date] despite using &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;CALCULATE( COUNTROWS( WorkOrders ),&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;FILTER( ALL( WorkOrders[Compliance Date], WorkOrders[Finish Date] ),&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How would one clear the context filter created by Dates[End of Week], shown on the axis on the visual, so that it does not filter the WorkOrders table, but still retain all other context filters? The concept is similar to calculating running/cumulative totals, but the examples I find on the Internet all use columns from the same table as the one filtered, not from related dimension tables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW I have used both formulas successfully with fact tables that are unrelated to the Dates dimension; it is the relationship with Dates that introduces the additional context filtering that I am trying to get rid of.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 07:56:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-temporary-table-variable-to-simplify-CALCULATE/m-p/2538157#M71408</guid>
      <dc:creator>fretief</dc:creator>
      <dc:date>2022-05-25T07:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using a temporary table variable to simplify CALCULATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-temporary-table-variable-to-simplify-CALCULATE/m-p/2538309#M71421</link>
      <description>&lt;P&gt;You can use REMOVEFILTERS to remove the context filters from a table or column(s) from a table, so REMOVEFILTERS('Date'[End of week]) might work in both cases.&lt;/P&gt;&lt;P&gt;One thing to bear in mind though, particularly with date tables, is that other helper columns from that table can also be added to the filter, usually sort order columns. You can check which columns are being used by using Performance Analyzer to grab the DAX code generated for the visual and check it in DAX Studio. Make sure that you either include all of them in the REMOVEFILTERS or just use the entire Date table in there.&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 08:43:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-temporary-table-variable-to-simplify-CALCULATE/m-p/2538309#M71421</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2022-05-25T08:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using a temporary table variable to simplify CALCULATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-temporary-table-variable-to-simplify-CALCULATE/m-p/2543107#M71687</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="367143" data-lia-user-login="fretief" class="lia-mention lia-mention-user"&gt;fretief&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;&lt;EM&gt;//Does one clear the filter context on the Date[End of Week] column (which is on the axis of the visual) or the WorkOrders[Compliance Date] column? How does one clear only the one context filter whilst retaining all the others?&amp;nbsp;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the function "REMOVEFILTERS" which&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="240987" data-lia-user-login="johnt75" class="lia-mention lia-mention-user"&gt;johnt75&lt;/a&gt;&amp;nbsp;mentioned. Or you can also try with ALL('Table'[Column]). You can find the difference between ALL(''Table) and&amp;nbsp;ALL('Table'[Column]) here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept/" target="_blank" rel="noopener"&gt;Managing “all” functions in DAX: ALL, ALLSELECTED, ALLNOBLANKROW, ALLEXCEPT - SQLBI&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;&lt;EM&gt;//I looked at KEEPFILTERS but struggle to understand how it works.&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can check these:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://dax.guide/keepfilters/" target="_blank" rel="noopener"&gt;KEEPFILTERS – DAX Guide&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=Cj6rI0fRCaQ" target="_blank" rel="noopener"&gt;KEEPFILTERS - DAX Guide - YouTube&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;&lt;EM&gt;//How would one clear the context filter created by Dates[End of Week], shown on the axis on the visual, so that it does not filter the WorkOrders table, but still retain all other context filters?&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Same as the first question, try what&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="240987" data-lia-user-login="johnt75" class="lia-mention lia-mention-user"&gt;johnt75&lt;/a&gt;&amp;nbsp;mentioned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Icey&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 07:53:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-temporary-table-variable-to-simplify-CALCULATE/m-p/2543107#M71687</guid>
      <dc:creator>Icey</dc:creator>
      <dc:date>2022-05-27T07:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using a temporary table variable to simplify CALCULATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-temporary-table-variable-to-simplify-CALCULATE/m-p/2548953#M72073</link>
      <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Thank you, John. REMOVEFILTERS does the job.&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;This formula works:&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;W/Orders O/Due (Related Date No Tmp Table) = &lt;BR /&gt;VAR SelectedEoWeek = SELECTEDVALUE( DatesRelated[End of Week] ) --- Relevant week end date obtained from visual &lt;BR /&gt;RETURN &lt;BR /&gt;    CALCULATE( COUNTROWS( WorkOrders ), &lt;BR /&gt;        REMOVEFILTERS( DatesRelated ),&lt;BR /&gt;        FILTER( ALL( WorkOrders[Compliance Date], WorkOrders[Finish Date] ), &lt;BR /&gt;            ( &lt;BR /&gt;                WorkOrders[Finish Date] = BLANK() &amp;amp;&amp;amp;                      --- WO does not have a finish date (still open)&lt;BR /&gt;                WorkOrders[Compliance Date] &amp;lt;= SelectedEoWeek   --- SelectedEOWeek is after Compliance Date&lt;BR /&gt;            ) &lt;BR /&gt;            ||&lt;BR /&gt;            ( &lt;BR /&gt;                WorkOrders[Finish Date] &amp;lt;&amp;gt; BLANK() &amp;amp;&amp;amp;                          --- WO has a finish date (closed)&lt;BR /&gt;                WorkOrders[Compliance Date] &amp;lt;= SelectedEoWeek &amp;amp;&amp;amp;   --- SelectedEOWeek falls between Compliance Date...&lt;BR /&gt;                SelectedEoWeek &amp;lt; WorkOrders[Finish Date]                     --- ... and Finish Date &lt;BR /&gt;            ) &lt;BR /&gt;        )&lt;BR /&gt;    ) &lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;However, I don't understand the logic: I would have thought that REMOVEFILTERS( DatesRelated ) would be sufficient to clear filters created by the visual on the DatesRelated dimension, and therefore the WorkOrders fact table would not be filtered by any dates. However, when I replace&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;FILTER( ALL( WorkOrders[Compliance Date], WorkOrders[Finish Date] ),&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;with FILTER( WorkOrders , the dates context is imposed again. Why does one have to clear filters on both the dimension and fact table dates columns? What is the sequence of steps here, first apply REMOVEFILTERS and then FILTER, or first FILTER then REMOVEFILTERS?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;I have spent about three days on this, reading many articles including the following ones that deal with the same topic:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;A href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/Removefilters-not-working/m-p/1488132" target="_blank"&gt;https://community.powerbi.com/t5/DAX-Commands-and-Tips/Removefilters-not-working/m-p/1488132&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/RemoveFilters-is-not-working/m-p/2524570" target="_blank"&gt;https://community.powerbi.com/t5/DAX-Commands-and-Tips/RemoveFilters-is-not-working/m-p/2524570&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Desktop/Removefilters-not-working-with-Date-Hierarchy/m-p/2196968" target="_blank"&gt;https://community.powerbi.com/t5/Desktop/Removefilters-not-working-with-Date-Hierarchy/m-p/2196968&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.reddit.com/r/PowerBI/comments/pmbmh3/removefilter_does_not_remove_the_context_filter/" target="_blank"&gt;https://www.reddit.com/r/PowerBI/comments/pmbmh3/removefilter_does_not_remove_the_context_filter/&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://dax.guide/calculate/" target="_blank"&gt;https://dax.guide/calculate/&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.sqlbi.com/articles/order-of-evaluation-in-calculate-parameters/" target="_blank"&gt;https://www.sqlbi.com/articles/order-of-evaluation-in-calculate-parameters/&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;A description of what CALCULATE actually does in its black box would be very helpful.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2022 04:27:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-temporary-table-variable-to-simplify-CALCULATE/m-p/2548953#M72073</guid>
      <dc:creator>fretief</dc:creator>
      <dc:date>2022-05-31T04:27:26Z</dc:date>
    </item>
  </channel>
</rss>

