<?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: CALCULATE/FILTER measure Gives a different result to table and filter in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-FILTER-measure-Gives-a-different-result-to-table-and/m-p/3719811#M144830</link>
    <description>&lt;P&gt;Based on the information you provided, it seems that the issue you are facing is related to the difference between the filter context in the visual and the filter context in the measure. The&lt;SPAN&gt;&amp;nbsp;CALCULATE&lt;SPAN&gt;&amp;nbsp;function allows simple filters which will replace the existing filter context. In your example,&lt;SPAN&gt;&amp;nbsp;CALCULATE&lt;SPAN&gt;&amp;nbsp;will compute the measure using the existing filter context, except that it removes any existing filter context for the column specified in the&lt;SPAN&gt;&amp;nbsp;FILTER&lt;SPAN&gt;&amp;nbsp;function and replaces it with the new filter condition.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One possible solution could be to check the filter context in the visual and make sure it is the same as the one specified in the&lt;SPAN&gt;&amp;nbsp;FILTER&lt;SPAN&gt;&amp;nbsp;function of the measure. You could also try to modify the measure to include additional filter conditions to match the filter context in the visual.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Here is an example of a DAX code that you can use to modify the measure to include additional filter conditions to match the filter context in the visual:&lt;/P&gt;&lt;PRE&gt;Measure =
CALCULATE (
    SUM ( BI_Fact_Activity[VacancyAddedCount] ),
    FILTER (
        BI_Vacancy,
        BI_Vacancy[eDate] = DATE ( 2222, 02, 22 )
    ),
    FILTER (
        RELATEDTABLE ( BI_Fact_Activity ),
        BI_Fact_Activity[GUID] = RELATED ( BI_Vacancy[GUID] )
    )
)&lt;/PRE&gt;&lt;P&gt;This code uses the&lt;SPAN&gt;&amp;nbsp;CALCULATE&lt;SPAN&gt;&amp;nbsp;function to compute the sum of the&lt;SPAN&gt;&amp;nbsp;VacancyAddedCount&lt;SPAN&gt;&amp;nbsp;column in the&lt;SPAN&gt;&amp;nbsp;BI_Fact_Activity&lt;SPAN&gt;&amp;nbsp;table, while applying two filter conditions. The first filter condition specifies that only rows in the&lt;SPAN&gt;&amp;nbsp;BI_Vacancy&lt;SPAN&gt;&amp;nbsp;table where the value of the&lt;SPAN&gt;&amp;nbsp;eDate&lt;SPAN&gt;&amp;nbsp;column is equal to&lt;SPAN&gt;&amp;nbsp;DATE(2222,02,22)&lt;SPAN&gt;&amp;nbsp;should be included in the calculation. The second filter condition specifies that only rows in the&lt;SPAN&gt;&amp;nbsp;BI_Fact_Activity&lt;SPAN&gt;&amp;nbsp;table where the value of the&lt;SPAN&gt;&amp;nbsp;GUID&lt;SPAN&gt;&amp;nbsp;column is equal to the value of the&lt;SPAN&gt;&amp;nbsp;GUID&lt;SPAN&gt;&amp;nbsp;column in the related row in the&lt;SPAN&gt;&amp;nbsp;BI_Vacancy&lt;SPAN&gt;&amp;nbsp;table should be included in the calculation.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code is just an example and you may need to modify it to match the specific details of your data model and the filter context in your visual.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Johannes&lt;/P&gt;</description>
    <pubDate>Fri, 23 Feb 2024 12:45:50 GMT</pubDate>
    <dc:creator>jolind1996</dc:creator>
    <dc:date>2024-02-23T12:45:50Z</dc:date>
    <item>
      <title>CALCULATE/FILTER measure Gives a different result to table and filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-FILTER-measure-Gives-a-different-result-to-table-and/m-p/3719735#M144827</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two tables: 1 is an activity table and 1 is a history table. They are linked by unique GUIDs. If I display a visual and sum a column from the activity table and apply a filter, I get the correct data (i.e. returns 3 entries). If I use the following measure, it returns only 2 (essentially ignores one fo them):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;calculate(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sum(BI_Fact_Activity[VacancyAddedCount]),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; filter(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BI_Vacancy,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BI_Vacancy[eDate] = DATE(2222,02,22)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;BR /&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Ultimately, I want to sum the AddCount column where the relevant GUID link the BI_Vacancy table has an eDate of 22/02/2222.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 23 Feb 2024 12:00:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-FILTER-measure-Gives-a-different-result-to-table-and/m-p/3719735#M144827</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-02-23T12:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: CALCULATE/FILTER measure Gives a different result to table and filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-FILTER-measure-Gives-a-different-result-to-table-and/m-p/3719811#M144830</link>
      <description>&lt;P&gt;Based on the information you provided, it seems that the issue you are facing is related to the difference between the filter context in the visual and the filter context in the measure. The&lt;SPAN&gt;&amp;nbsp;CALCULATE&lt;SPAN&gt;&amp;nbsp;function allows simple filters which will replace the existing filter context. In your example,&lt;SPAN&gt;&amp;nbsp;CALCULATE&lt;SPAN&gt;&amp;nbsp;will compute the measure using the existing filter context, except that it removes any existing filter context for the column specified in the&lt;SPAN&gt;&amp;nbsp;FILTER&lt;SPAN&gt;&amp;nbsp;function and replaces it with the new filter condition.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One possible solution could be to check the filter context in the visual and make sure it is the same as the one specified in the&lt;SPAN&gt;&amp;nbsp;FILTER&lt;SPAN&gt;&amp;nbsp;function of the measure. You could also try to modify the measure to include additional filter conditions to match the filter context in the visual.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Here is an example of a DAX code that you can use to modify the measure to include additional filter conditions to match the filter context in the visual:&lt;/P&gt;&lt;PRE&gt;Measure =
CALCULATE (
    SUM ( BI_Fact_Activity[VacancyAddedCount] ),
    FILTER (
        BI_Vacancy,
        BI_Vacancy[eDate] = DATE ( 2222, 02, 22 )
    ),
    FILTER (
        RELATEDTABLE ( BI_Fact_Activity ),
        BI_Fact_Activity[GUID] = RELATED ( BI_Vacancy[GUID] )
    )
)&lt;/PRE&gt;&lt;P&gt;This code uses the&lt;SPAN&gt;&amp;nbsp;CALCULATE&lt;SPAN&gt;&amp;nbsp;function to compute the sum of the&lt;SPAN&gt;&amp;nbsp;VacancyAddedCount&lt;SPAN&gt;&amp;nbsp;column in the&lt;SPAN&gt;&amp;nbsp;BI_Fact_Activity&lt;SPAN&gt;&amp;nbsp;table, while applying two filter conditions. The first filter condition specifies that only rows in the&lt;SPAN&gt;&amp;nbsp;BI_Vacancy&lt;SPAN&gt;&amp;nbsp;table where the value of the&lt;SPAN&gt;&amp;nbsp;eDate&lt;SPAN&gt;&amp;nbsp;column is equal to&lt;SPAN&gt;&amp;nbsp;DATE(2222,02,22)&lt;SPAN&gt;&amp;nbsp;should be included in the calculation. The second filter condition specifies that only rows in the&lt;SPAN&gt;&amp;nbsp;BI_Fact_Activity&lt;SPAN&gt;&amp;nbsp;table where the value of the&lt;SPAN&gt;&amp;nbsp;GUID&lt;SPAN&gt;&amp;nbsp;column is equal to the value of the&lt;SPAN&gt;&amp;nbsp;GUID&lt;SPAN&gt;&amp;nbsp;column in the related row in the&lt;SPAN&gt;&amp;nbsp;BI_Vacancy&lt;SPAN&gt;&amp;nbsp;table should be included in the calculation.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code is just an example and you may need to modify it to match the specific details of your data model and the filter context in your visual.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Johannes&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2024 12:45:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-FILTER-measure-Gives-a-different-result-to-table-and/m-p/3719811#M144830</guid>
      <dc:creator>jolind1996</dc:creator>
      <dc:date>2024-02-23T12:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: CALCULATE/FILTER measure Gives a different result to table and filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-FILTER-measure-Gives-a-different-result-to-table-and/m-p/3723389#M144997</link>
      <description>&lt;P&gt;I'd respond in case anyone encounters the same issue. I fixed it by wrapping the filter table in ALL(), can only assume SOMETHING was impacting on the data being filtered, but this did the trick:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;calculate(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sum(BI_Fact_Activity[VacancyAddedCount]),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; filter(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ALL(BI_Vacancy),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BI_Vacancy[eDate] = DATE(2222,02,22)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;BR /&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 26 Feb 2024 09:09:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATE-FILTER-measure-Gives-a-different-result-to-table-and/m-p/3723389#M144997</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-02-26T09:09:51Z</dc:date>
    </item>
  </channel>
</rss>

