<?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 function does not filter data in Report Server</title>
    <link>https://community.fabric.microsoft.com/t5/Report-Server/CALCULATE-function-does-not-filter-data/m-p/2362072#M23074</link>
    <description>&lt;P&gt;You may be overcomplicating things a bit. Read about the EDATE() function. Also, your comparators are the wrong way round.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;pbi_inc[yymm] &amp;gt;=lm , pbi_inc[yymm] &amp;lt;=r12m&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;you should use&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;pbi_inc[yymm] &amp;lt;=lm , pbi_inc[yymm] &amp;gt;=r12m&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 26 Feb 2022 00:59:24 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2022-02-26T00:59:24Z</dc:date>
    <item>
      <title>CALCULATE function does not filter data</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/CALCULATE-function-does-not-filter-data/m-p/2359188#M23038</link>
      <description>&lt;P&gt;I am trying to use the CALCULATE function in DAX to find sum of income in last 12 months. The measure I am using is as below&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sub measures&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Latest Month in Table = MAX(pbi_inc[yymm])&lt;BR /&gt;Samemonth_prev year = [Latest Month in Table] -100&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Main DAX:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;income_inc=&lt;BR /&gt;var lm = [Latest Month in Table]&lt;/P&gt;&lt;P&gt;var r12m = [ Samemonth_prev year]&lt;/P&gt;&lt;P&gt;return CALCULATE(SUM(pbi_inc[inc], pbi_inc[ic/cr] =1,pbi_inc[yymm] &amp;gt;=lm , pbi_inc[yymm] &amp;lt;=r12m)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue I am facing is the Calculate function is not filtering data for yymm. It filters data when I change the ic/cr value but not for yymm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works fine when I hardcode to something like 2112 but not when I use variables and submeasures.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have compared the data types and spaces and all are compatible. All fields are taken from the same fact table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can some one please help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 15:34:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/CALCULATE-function-does-not-filter-data/m-p/2359188#M23038</guid>
      <dc:creator>SaiSpandana2811</dc:creator>
      <dc:date>2022-02-24T15:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: CALCULATE function does not filter data</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/CALCULATE-function-does-not-filter-data/m-p/2362072#M23074</link>
      <description>&lt;P&gt;You may be overcomplicating things a bit. Read about the EDATE() function. Also, your comparators are the wrong way round.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;pbi_inc[yymm] &amp;gt;=lm , pbi_inc[yymm] &amp;lt;=r12m&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;you should use&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;pbi_inc[yymm] &amp;lt;=lm , pbi_inc[yymm] &amp;gt;=r12m&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Feb 2022 00:59:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/CALCULATE-function-does-not-filter-data/m-p/2362072#M23074</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2022-02-26T00:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: CALCULATE function does not filter data</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/CALCULATE-function-does-not-filter-data/m-p/2366469#M23109</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="325072" data-lia-user-login="SaiSpandana2811" class="lia-mention lia-mention-user"&gt;SaiSpandana2811&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you can try to use the DATESINPERIOD function to quickly solve for the sum over the past period of dates. Refer to the following formula:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;M_ =
CALCULATE (
    SUM ( 'Table'[Value] ),
    DATESINPERIOD ( 'Table'[Date], MAX ( 'Table'[Date] ), -12, MONTH )
)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Or create a date column and dynamically filter a date to find the sum over time.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;M_1 =
CALCULATE (
    SUM ( 'Table'[Value] ),
    DATESINPERIOD ( 'Table'[Date], SELECTEDVALUE ( Tab_data[Date] ), -12, MONTH )
)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Also you can read related blog for more details:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gorilla.bi/dax/5-ways-to-calculate-last-12-months-in-dax/" target="_blank"&gt;5 ways to calculate last 12 months in DAX for Power BI - BI Gorilla&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Desktop/How-to-calculate-last-12-months/td-p/1647508" target="_blank"&gt;Solved: How to calculate last 12 months - Microsoft Power BI Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Henry&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If this post &lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 06:43:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/CALCULATE-function-does-not-filter-data/m-p/2366469#M23109</guid>
      <dc:creator>v-henryk-mstf</dc:creator>
      <dc:date>2022-03-01T06:43:35Z</dc:date>
    </item>
  </channel>
</rss>

