<?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 Passing a Variable not working in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Passing-a-Variable-not-working/m-p/3084126#M107668</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope you will be able to help me to understand why the variables in DAX do not work as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I create a measure as the below, it doesn't work (doesn't return the desired outcome):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;x_Achieved = 
VAR CurrentQTR = LOOKUPVALUE(Dates[Academic_Year_Quarter],Dates[Date],MAX(c_Enrolments[Date Exported On]))
VAR IsAchieved = FILTER(c_Enrolments,c_Enrolments[CompletionID]=2 &amp;amp;&amp;amp; c_Enrolments[OutcomeID]=1 )
RETURN CALCULATE(COUNTROWS(c_Enrolments),FILTER(Dates_AED,Dates_AED[Academic_Year_Quarter]=CurrentQTR),IsAchieved)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once I change the CurrentQTR to an actual string, it seems to work correctly (returns what is expected):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;x_Achieved = 
//VAR CurrentQTR = LOOKUPVALUE(Dates[Academic_Year_Quarter],Dates[Date],MAX(c_Enrolments[Date Exported On]))
VAR IsAchieved = FILTER(c_Enrolments,c_Enrolments[CompletionID]=2 &amp;amp;&amp;amp; c_Enrolments[OutcomeID]=1 )
RETURN CALCULATE(COUNTROWS(c_Enrolments),FILTER(Dates_AED,Dates_AED[Academic_Year_Quarter]="22/23 - Q4"),IsAchieved)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I evaluate the CurrentQTR calculated using the LOOKUPVALUE and pass it into a Card visual, it shows exactly the desired value, "22/23 - Q4".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am baffled as I have no idea why it has decided not to work...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sure it must be something silly and simple, but I am stuck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks for your time &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Feb 2023 22:37:38 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-02-16T22:37:38Z</dc:date>
    <item>
      <title>Passing a Variable not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Passing-a-Variable-not-working/m-p/3084126#M107668</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope you will be able to help me to understand why the variables in DAX do not work as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I create a measure as the below, it doesn't work (doesn't return the desired outcome):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;x_Achieved = 
VAR CurrentQTR = LOOKUPVALUE(Dates[Academic_Year_Quarter],Dates[Date],MAX(c_Enrolments[Date Exported On]))
VAR IsAchieved = FILTER(c_Enrolments,c_Enrolments[CompletionID]=2 &amp;amp;&amp;amp; c_Enrolments[OutcomeID]=1 )
RETURN CALCULATE(COUNTROWS(c_Enrolments),FILTER(Dates_AED,Dates_AED[Academic_Year_Quarter]=CurrentQTR),IsAchieved)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once I change the CurrentQTR to an actual string, it seems to work correctly (returns what is expected):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;x_Achieved = 
//VAR CurrentQTR = LOOKUPVALUE(Dates[Academic_Year_Quarter],Dates[Date],MAX(c_Enrolments[Date Exported On]))
VAR IsAchieved = FILTER(c_Enrolments,c_Enrolments[CompletionID]=2 &amp;amp;&amp;amp; c_Enrolments[OutcomeID]=1 )
RETURN CALCULATE(COUNTROWS(c_Enrolments),FILTER(Dates_AED,Dates_AED[Academic_Year_Quarter]="22/23 - Q4"),IsAchieved)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I evaluate the CurrentQTR calculated using the LOOKUPVALUE and pass it into a Card visual, it shows exactly the desired value, "22/23 - Q4".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am baffled as I have no idea why it has decided not to work...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sure it must be something silly and simple, but I am stuck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks for your time &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 22:37:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Passing-a-Variable-not-working/m-p/3084126#M107668</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-16T22:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a Variable not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Passing-a-Variable-not-working/m-p/3084141#M107669</link>
      <description>&lt;P&gt;hi Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;most probably because the filter context is different. What filter context do you have for your first code? filter context includes visual columns, rows, axis, filter pane setting, slicer selection.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your first code, try to&lt;/P&gt;&lt;P&gt;RETURN CurrentQTR&lt;/P&gt;&lt;P&gt;what do you get?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 23:16:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Passing-a-Variable-not-working/m-p/3084141#M107669</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-02-16T23:16:14Z</dc:date>
    </item>
  </channel>
</rss>

