<?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 Issue with SELECTEDVALUE function when used with CALCULATETABLE in DAX in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-SELECTEDVALUE-function-when-used-with-CALCULATETABLE/m-p/3809522#M148962</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently working on a report where I've dedicated a page to individual companies. Users navigate to this page via "drill through" from another page. On this particular page, I would like to see other companies that are within the same industry as the company in question. With that aim, I have constructed the following DAX formula:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SummarizeTable = 

VAR CurrentIndustry = SELECTEDVALUE('Account Meta Data'[Industry])

VAR CompanyList = CALCULATETABLE( 
    VALUES('Account Meta Data'[DatabaseName]), 
    'Account Meta Data'[Industry] = CurrentIndustry
)

Return
CompanyList&lt;/LI-CODE&gt;&lt;P&gt;However, the CompanyList produced doesn't align with my expectation. It seems to comprise of companies which lack industry definitions in my Company Meta Table. Although I have tested the CurrentIndustry = SELECTEDVALUE('Account Meta Data'[Industry]) measure separately and confirmed it produces the correct value, it doesn't seem to function as intended within the CALCULATETABLE function. When I replace CurrentIndustry with a specific industry value (for example, "Agriculture"), the list is generated correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone kindly help me understand what might be wrong? Any assistance would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Brenda&lt;/P&gt;</description>
    <pubDate>Thu, 04 Apr 2024 06:47:34 GMT</pubDate>
    <dc:creator>Yiyi_1989</dc:creator>
    <dc:date>2024-04-04T06:47:34Z</dc:date>
    <item>
      <title>Issue with SELECTEDVALUE function when used with CALCULATETABLE in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-SELECTEDVALUE-function-when-used-with-CALCULATETABLE/m-p/3809522#M148962</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently working on a report where I've dedicated a page to individual companies. Users navigate to this page via "drill through" from another page. On this particular page, I would like to see other companies that are within the same industry as the company in question. With that aim, I have constructed the following DAX formula:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SummarizeTable = 

VAR CurrentIndustry = SELECTEDVALUE('Account Meta Data'[Industry])

VAR CompanyList = CALCULATETABLE( 
    VALUES('Account Meta Data'[DatabaseName]), 
    'Account Meta Data'[Industry] = CurrentIndustry
)

Return
CompanyList&lt;/LI-CODE&gt;&lt;P&gt;However, the CompanyList produced doesn't align with my expectation. It seems to comprise of companies which lack industry definitions in my Company Meta Table. Although I have tested the CurrentIndustry = SELECTEDVALUE('Account Meta Data'[Industry]) measure separately and confirmed it produces the correct value, it doesn't seem to function as intended within the CALCULATETABLE function. When I replace CurrentIndustry with a specific industry value (for example, "Agriculture"), the list is generated correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone kindly help me understand what might be wrong? Any assistance would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Brenda&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 06:47:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-SELECTEDVALUE-function-when-used-with-CALCULATETABLE/m-p/3809522#M148962</guid>
      <dc:creator>Yiyi_1989</dc:creator>
      <dc:date>2024-04-04T06:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with SELECTEDVALUE function when used with CALCULATETABLE in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-SELECTEDVALUE-function-when-used-with-CALCULATETABLE/m-p/3810552#M149031</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="591510" data-lia-user-login="Yiyi_1989" class="lia-mention lia-mention-user"&gt;Yiyi_1989&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;It seems your formula don't produce a scalar value but a table with more than one value. I don't Know if this is the problem.&lt;BR /&gt;Can you share one pbix file with same data so I can take a look?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 11:11:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-SELECTEDVALUE-function-when-used-with-CALCULATETABLE/m-p/3810552#M149031</guid>
      <dc:creator>_AAndrade</dc:creator>
      <dc:date>2024-04-04T11:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with SELECTEDVALUE function when used with CALCULATETABLE in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-SELECTEDVALUE-function-when-used-with-CALCULATETABLE/m-p/3810693#M149035</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="690039" data-lia-user-login="_AAndrade" class="lia-mention lia-mention-user"&gt;_AAndrade&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for promptly responding to my query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To add some clarity, I would like to generate a list of companies that are in the same industry as the industry selected on a particular page. This data is to be extracted from the 'Account Meta Data' table.The 'Account Meta Data' table consists of several details such as the Company name, Database Name, Industry, and more. My goal is to filter this table based on industry and create a list showcasing the names of the companies within that industry.&lt;/P&gt;&lt;P&gt;To illustrate, if a specific company page filters for 'Software' industry, I'd aim to generate a 'Software' industry-specific list of companies from the 'Account Meta Data' table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Due to the confidentiality of my data, I’m unable to share explicit data. I would really appreciate if you have some general suggestion about what I should check. Thanks a lot!!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 11:51:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-SELECTEDVALUE-function-when-used-with-CALCULATETABLE/m-p/3810693#M149035</guid>
      <dc:creator>Yiyi_1989</dc:creator>
      <dc:date>2024-04-04T11:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with SELECTEDVALUE function when used with CALCULATETABLE in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-SELECTEDVALUE-function-when-used-with-CALCULATETABLE/m-p/3812293#M149101</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thank&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="690039" data-lia-user-login="_AAndrade" class="lia-mention lia-mention-user"&gt;_AAndrade&lt;/a&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;for your prompt reply.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="591510" data-lia-user-login="Yiyi_1989" class="lia-mention lia-mention-user"&gt;Yiyi_1989&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Based on your description of the problem, the heart of the issue seems to be how the CALCULATETABLE function interprets the CurrentIndustry variable in its filtering context. Here is a modification to your DAX formula that should solve the problem:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SummarizeTable =
VAR CurrentIndustry =
    SELECTEDVALUE ( 'Account Meta Data'[Industry] )
VAR CompanyList =
    CALCULATETABLE (
        VALUES ( 'Account Meta Data'[DatabaseName] ),
        FILTER ( 'Account Meta Data', 'Account Meta Data'[Industry] = CurrentIndustry )
    )
RETURN
    CompanyList
&lt;/LI-CODE&gt;
&lt;P&gt;I encapsulated the filter condition with the FILTER function. This explicitly creates row context for each row in the &lt;SPAN&gt;Company Meta&lt;/SPAN&gt; table so that comparisons between each company's industry and the CurrentIndustry variable can be evaluated correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CALCULATETABLE Functions:&lt;A href="https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-calculated-tables" target="_blank"&gt;Using calculated tables in Power BI Desktop - Power BI | Microsoft Learn&lt;/A&gt;&lt;BR /&gt;Try this modified formula to see if it works as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank" rel="noopener"&gt;How to Get Your Question Answered Quickly - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If it does not help, please provide more details with your desired out put and pbix file without privacy information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Ada Wang&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;Accept it as the solution&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2024 02:16:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-SELECTEDVALUE-function-when-used-with-CALCULATETABLE/m-p/3812293#M149101</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-05T02:16:26Z</dc:date>
    </item>
  </channel>
</rss>

