<?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 Using DAX variables in the filter function in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-DAX-variables-in-the-filter-function/m-p/2181284#M50778</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to create a measure and at a given moment I use the following expression:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Top =&lt;BR /&gt;VAR Nth = 2&lt;BR /&gt;VAR Category = ALLSELECTED(Table[Category])&lt;BR /&gt;VAR Sales =&lt;BR /&gt;ADDCOLUMNS(&lt;BR /&gt;VALUES(Table[Category]),,"Rank",RANKX(Category,[Total Sales]))&lt;/P&gt;&lt;P&gt;VAR FilterNThCategory = FILTER(Sales , [Rank] = Nth)&lt;BR /&gt;VAR NthLineName = MINX(FilterNThLine,Table[Category])&lt;BR /&gt;VAR Subtop = CALCULATE([Total Sales],Table[Category] = NthLineName)&lt;/P&gt;&lt;P&gt;return Subtop&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in theory the return of the variable "NthLineName" is a string, but when I use it inside the FILTER function, I don't get the expected result. However, when I replace "NthLineName" with the string "Cars", it works perfectly.&lt;/P&gt;&lt;P&gt;Does the FILTER function not support the use of variables or am I doing something wrong? is there any way to get around it?&lt;/P&gt;&lt;P&gt;thank you very much in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Nov 2021 20:29:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-11-09T20:29:25Z</dc:date>
    <item>
      <title>Using DAX variables in the filter function</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-DAX-variables-in-the-filter-function/m-p/2181284#M50778</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to create a measure and at a given moment I use the following expression:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Top =&lt;BR /&gt;VAR Nth = 2&lt;BR /&gt;VAR Category = ALLSELECTED(Table[Category])&lt;BR /&gt;VAR Sales =&lt;BR /&gt;ADDCOLUMNS(&lt;BR /&gt;VALUES(Table[Category]),,"Rank",RANKX(Category,[Total Sales]))&lt;/P&gt;&lt;P&gt;VAR FilterNThCategory = FILTER(Sales , [Rank] = Nth)&lt;BR /&gt;VAR NthLineName = MINX(FilterNThLine,Table[Category])&lt;BR /&gt;VAR Subtop = CALCULATE([Total Sales],Table[Category] = NthLineName)&lt;/P&gt;&lt;P&gt;return Subtop&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in theory the return of the variable "NthLineName" is a string, but when I use it inside the FILTER function, I don't get the expected result. However, when I replace "NthLineName" with the string "Cars", it works perfectly.&lt;/P&gt;&lt;P&gt;Does the FILTER function not support the use of variables or am I doing something wrong? is there any way to get around it?&lt;/P&gt;&lt;P&gt;thank you very much in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Nov 2021 20:29:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-DAX-variables-in-the-filter-function/m-p/2181284#M50778</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-11-09T20:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using DAX variables in the filter function</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-DAX-variables-in-the-filter-function/m-p/2181331#M50780</link>
      <description>&lt;P&gt;Does it help if you replace VALUES ( Table[Category] ) with Category?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not, then can you provide some example data and desired results to test against?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Nov 2021 21:25:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-DAX-variables-in-the-filter-function/m-p/2181331#M50780</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2021-11-09T21:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Using DAX variables in the filter function</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-DAX-variables-in-the-filter-function/m-p/2186455#M50999</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please make a little bit change to your measure.&lt;/P&gt;
&lt;P&gt;Top =&lt;/P&gt;
&lt;P&gt;VAR Nth = 2&lt;/P&gt;
&lt;P&gt;VAR Category =&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ALLSELECTED ( 'Table'[Category] )&lt;/P&gt;
&lt;P&gt;VAR Sales_ =&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADDCOLUMNS(&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VALUES ('Table'[Category]),&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Rank", RANKX ( Category, [Total Sales] )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;
&lt;P&gt;VAR FilterNThCategory =&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FILTER(Sales_,[Rank]=Nth)&lt;/P&gt;
&lt;P&gt;VAR NthLineName =&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MINX(&lt;STRONG&gt;FilterNThCategory&lt;/STRONG&gt;,'Table'[Category])&lt;/P&gt;
&lt;P&gt;VAR Subtop =&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CALCULATE ( [Total Sales], 'Table'[Category] =NthLineName)&lt;/P&gt;
&lt;P&gt;RETURN&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Subtop&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result should look like this:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Attached the pbix file as reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Community Support Team _ Caiyun&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;to help the other members find it more quickly. If you still have problems on it, please feel free to let us know. Thanks a lot!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Nov 2021 02:55:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-DAX-variables-in-the-filter-function/m-p/2186455#M50999</guid>
      <dc:creator>v-cazheng-msft</dc:creator>
      <dc:date>2021-11-12T02:55:08Z</dc:date>
    </item>
  </channel>
</rss>

