<?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 Calculate and filter context in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-and-filter-context/m-p/3050476#M105052</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I guess this is a simple question but I am going nuts why it doesn't work. So as far I studied DAX book and read your articles I know that if we add an filter as a CALCULTE argument adds a filter to the filter context or replaces it (when it filters same column). So why it does not work in this example - I have a date table with some additional columns like ("Month Year") which are used as rows in matrix:&lt;BR /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My measure is:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE(
[Sales Amount],
Daty[Date]= DATE(2023,1,27)
)&lt;/LI-CODE&gt;&lt;P&gt;So outer filter context in this matrix is set for &lt;EM&gt;Dates[Month Year]&lt;/EM&gt; column (in rows). In a measure I use filter for &lt;EM&gt;Dates[Date]&lt;/EM&gt;. So at each row there is a filter Month-Year and Calculate adds &lt;EM&gt;Daty[Date]= DATE(2023,1,27)&lt;/EM&gt;. So final filter context uses 2 columns &lt;EM&gt;Dates[Date]&lt;/EM&gt; and &lt;EM&gt;Dates[Month Year].&lt;/EM&gt; The filter from CALCULTE does not remove any filter here as it uses different column for filtering. So why I am getting same value in every row? As an example the row with filter February 2023 AND DATE(2023,1,27) should be empty but it gives Sales from 27.1.2023. So there should be result only in January.&amp;nbsp; If a use any other column from Dates table in CALCULTE argument it works like it should.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Jan 2023 13:33:37 GMT</pubDate>
    <dc:creator>Zx2000</dc:creator>
    <dc:date>2023-01-30T13:33:37Z</dc:date>
    <item>
      <title>Calculate and filter context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-and-filter-context/m-p/3050476#M105052</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I guess this is a simple question but I am going nuts why it doesn't work. So as far I studied DAX book and read your articles I know that if we add an filter as a CALCULTE argument adds a filter to the filter context or replaces it (when it filters same column). So why it does not work in this example - I have a date table with some additional columns like ("Month Year") which are used as rows in matrix:&lt;BR /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My measure is:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE(
[Sales Amount],
Daty[Date]= DATE(2023,1,27)
)&lt;/LI-CODE&gt;&lt;P&gt;So outer filter context in this matrix is set for &lt;EM&gt;Dates[Month Year]&lt;/EM&gt; column (in rows). In a measure I use filter for &lt;EM&gt;Dates[Date]&lt;/EM&gt;. So at each row there is a filter Month-Year and Calculate adds &lt;EM&gt;Daty[Date]= DATE(2023,1,27)&lt;/EM&gt;. So final filter context uses 2 columns &lt;EM&gt;Dates[Date]&lt;/EM&gt; and &lt;EM&gt;Dates[Month Year].&lt;/EM&gt; The filter from CALCULTE does not remove any filter here as it uses different column for filtering. So why I am getting same value in every row? As an example the row with filter February 2023 AND DATE(2023,1,27) should be empty but it gives Sales from 27.1.2023. So there should be result only in January.&amp;nbsp; If a use any other column from Dates table in CALCULTE argument it works like it should.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 13:33:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-and-filter-context/m-p/3050476#M105052</guid>
      <dc:creator>Zx2000</dc:creator>
      <dc:date>2023-01-30T13:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate and filter context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-and-filter-context/m-p/3050519#M105054</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Your measure returns always the same value (the sales of 27.1.2023). Now what is happening is that you have hard-coded a filter to your measure. So basically your measure = "calculate sales from fact table, but only consider the values on date 27.1.2023. Since your visual uses values from your calendar table an you likely have 1:m relationship between your fact and calendar table, from your visuals perspective every month will get the same value. E.g on February the measure will still get the same value since it considers the 27.1.2023 date. However if you were to use data from your fact table your visual would make sense:&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;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Measure 38 = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table (22)'&lt;/SPAN&gt;&lt;SPAN&gt;[Column1]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;'Calendar'&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;DATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;2023&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;Using column from calendar:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;using column from fact:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Only January gets values so only it is displayed.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!&lt;BR /&gt;&lt;BR /&gt;My LinkedIn: &lt;A href="https://www.linkedin.com/in/n%C3%A4ttiahov-00001/" target="_blank"&gt;https://www.linkedin.com/in/n%C3%A4ttiahov-00001/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 13:49:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-and-filter-context/m-p/3050519#M105054</guid>
      <dc:creator>ValtteriN</dc:creator>
      <dc:date>2023-01-30T13:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate and filter context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-and-filter-context/m-p/3050780#M105074</link>
      <description>&lt;P&gt;Actually I don't understand it. What means I hard coded it? These rules for CALCULATE works in every other table in a model.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 15:48:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-and-filter-context/m-p/3050780#M105074</guid>
      <dc:creator>Zx2000</dc:creator>
      <dc:date>2023-01-30T15:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate and filter context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-and-filter-context/m-p/3052123#M105177</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="495487" data-lia-user-login="Zx2000" class="lia-mention lia-mention-user"&gt;Zx2000&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is because a filter arugment inside a CALCULATE can overwrite outer fitlering context of a measure. In case of conflict, the filter argument prevails.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 09:00:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-and-filter-context/m-p/3052123#M105177</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-01-31T09:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate and filter context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-and-filter-context/m-p/3058319#M105585</link>
      <description>&lt;P&gt;So I found the solution. The solution is off course crazy becasue there is no clear information about this almost nowhere. Seems that DAX is real hell. So...as far as I understand:&amp;nbsp;&lt;BR /&gt;If someone uses calculate with [date] column and:&lt;/P&gt;&lt;P&gt;-[date] column is a connector to other tables&amp;nbsp; OR&lt;/P&gt;&lt;P&gt;-if table is &lt;U&gt;"marked as date table"&lt;/U&gt; (when a date table is connected with other table but by other column ie. DateKey)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;=&amp;gt; the ALL('date table") is added to the formula. This happend in the background (and of course almost no one knows it and you will not see it). Congrats for DAX developers.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 16:02:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-and-filter-context/m-p/3058319#M105585</guid>
      <dc:creator>Zx2000</dc:creator>
      <dc:date>2023-02-02T16:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate and filter context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-and-filter-context/m-p/3058320#M105586</link>
      <description>&lt;P&gt;This is wrong.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 15:54:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-and-filter-context/m-p/3058320#M105586</guid>
      <dc:creator>Zx2000</dc:creator>
      <dc:date>2023-02-02T15:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate and filter context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-and-filter-context/m-p/3058332#M105588</link>
      <description>&lt;P&gt;Nope. It is wrong. They overwrite filter when filtering the same column. There is no confilct here. There is a outer filter context (year - month) and new context (single date). In normal case it should be combined.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 15:59:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-and-filter-context/m-p/3058332#M105588</guid>
      <dc:creator>Zx2000</dc:creator>
      <dc:date>2023-02-02T15:59:14Z</dc:date>
    </item>
  </channel>
</rss>

