<?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 not filtering when a variable is used. in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-not-filtering-when-a-variable-is-used/m-p/3472100#M132589</link>
    <description>&lt;P&gt;Thank you so much for your prompt and helpful responses&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="284628" data-lia-user-login="Erokor" class="lia-mention lia-mention-user"&gt;Erokor&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&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;&lt;BR /&gt;This is why I love this community &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Oct 2023 20:09:47 GMT</pubDate>
    <dc:creator>sunilbeckham</dc:creator>
    <dc:date>2023-10-11T20:09:47Z</dc:date>
    <item>
      <title>Calculate function not filtering when a variable is used.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-not-filtering-when-a-variable-is-used/m-p/3472027#M132586</link>
      <description>&lt;P&gt;Hello everyone. I have a table that looks something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;School Division&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Student enrollment&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Month&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;Oct&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;Oct&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;Nov&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;Dec&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I create a simple calculate measure such as this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Students enrolled = 
CALCULATE(SUM('Table'[Student enrollment]),'Table'[Month] = "Oct")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the correct result, which in this example will be = 22&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I create a variable to store the Sum aggregate, I get a different result that is without any filter specified within Calculate function. For example this DAX:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Students enrolled = 
VAR _studentsenrolled = SUM('Table'[Student enrollment])
RETURN
CALCULATE(_studentsenrolled,'Table'[Month] = "Oct")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this example, it gives me the result as 47. Which is incorrect as it doesn't seem to be taking into account the filter parameter of Calculate function.&lt;BR /&gt;&lt;BR /&gt;Can anyone help clarify what am I missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 19:31:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-not-filtering-when-a-variable-is-used/m-p/3472027#M132586</guid>
      <dc:creator>sunilbeckham</dc:creator>
      <dc:date>2023-10-11T19:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate function not filtering when a variable is used.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-not-filtering-when-a-variable-is-used/m-p/3472041#M132587</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="500470" data-lia-user-login="sunilbeckham" class="lia-mention lia-mention-user"&gt;sunilbeckham&lt;/a&gt;&amp;nbsp;Doesn't work that way. Variables are not variable, they are static once calculated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 19:43:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-not-filtering-when-a-variable-is-used/m-p/3472041#M132587</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2023-10-11T19:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate function not filtering when a variable is used.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-not-filtering-when-a-variable-is-used/m-p/3472066#M132588</link>
      <description>&lt;P&gt;Echoing&amp;nbsp;&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;on this one, but with a little more information. Variables are calculated only once and then stored only once and cannot be re-used in their current context. The only exception to this is if you create a variable that is a table:&amp;nbsp;&lt;BR /&gt;&lt;EM&gt;ie.&lt;/EM&gt;&amp;nbsp;VAR _SourceTable = FILTER(ALL('Date'[Year]),'Date'[Year]&amp;gt;=2010)&amp;nbsp;&lt;BR /&gt;and then later on you want to further filter this source table &lt;EM&gt;ie.&amp;nbsp;&lt;/EM&gt;VAR _MoreFiltering = FILTER(_SourceTable, [Year] &amp;gt;= 2013).&lt;/P&gt;&lt;P&gt;Measures are calculated in the current filter context (sometimes that's okay if you want to keep the value static) but you can't use CALCULATE() to adjust that after the fact.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 19:53:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-not-filtering-when-a-variable-is-used/m-p/3472066#M132588</guid>
      <dc:creator>Erokor</dc:creator>
      <dc:date>2023-10-11T19:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate function not filtering when a variable is used.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-not-filtering-when-a-variable-is-used/m-p/3472100#M132589</link>
      <description>&lt;P&gt;Thank you so much for your prompt and helpful responses&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="284628" data-lia-user-login="Erokor" class="lia-mention lia-mention-user"&gt;Erokor&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&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;&lt;BR /&gt;This is why I love this community &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 20:09:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-not-filtering-when-a-variable-is-used/m-p/3472100#M132589</guid>
      <dc:creator>sunilbeckham</dc:creator>
      <dc:date>2023-10-11T20:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate function not filtering when a variable is used.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-not-filtering-when-a-variable-is-used/m-p/3472107#M132590</link>
      <description>&lt;P&gt;I've been a longtime lurker, and only today decided to leave my hermit cave and start answering questions. I guess imposter syndrom has kept me from replying &lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;.&amp;nbsp; Time to go for that Superuser cape.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 20:13:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-not-filtering-when-a-variable-is-used/m-p/3472107#M132590</guid>
      <dc:creator>Erokor</dc:creator>
      <dc:date>2023-10-11T20:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate function not filtering when a variable is used.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-not-filtering-when-a-variable-is-used/m-p/3472111#M132591</link>
      <description>&lt;P&gt;I can totally relate. Hopefully someday I'll gather enough wisdom from my lurking experience that I can leave my hermit cave too&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;&lt;BR /&gt;All the best in your quest for Superuser!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 20:19:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-not-filtering-when-a-variable-is-used/m-p/3472111#M132591</guid>
      <dc:creator>sunilbeckham</dc:creator>
      <dc:date>2023-10-11T20:19:17Z</dc:date>
    </item>
  </channel>
</rss>

