<?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: Values function works with separate table but not within same function in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Values-function-works-with-separate-table-but-not-within-same/m-p/3336680#M125148</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am not sure how your datamodel looks like, but please try something like below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;filtered production test =
VAR country_list =
    SUMMARIZE (
        TOPN (
            10,
            ALL ( capacity_production_by_plant[Country] ),
            CALCULATE (
                SUM ( capacity_production_by_plant[production] ),
                YEAR ( capacity_production_by_plant[year] ) = 2023
            )
        ),
        capacity_production_by_plant[Country]
    )
RETURN
    SUMX (
        FILTER (
            capacity_production_by_plant,
            capacity_production_by_plant[Country] IN country_list
        ),
        capacity_production_by_plant[production]
    )
&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 18 Jul 2023 14:11:18 GMT</pubDate>
    <dc:creator>Jihwan_Kim</dc:creator>
    <dc:date>2023-07-18T14:11:18Z</dc:date>
    <item>
      <title>Values function works with separate table but not within same function</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Values-function-works-with-separate-table-but-not-within-same/m-p/3336666#M125146</link>
      <description>&lt;P&gt;I have a table within Power BI that I created using the formula below.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;top_10_country_list_alternative = 
    topn(
    10,
    values(capacity_production_by_plant[Country]),
    calculate(sum(capacity_production_by_plant[production]),
    year(capacity_production_by_plant[year]) = 2023)
    )&lt;/LI-CODE&gt;&lt;P&gt;When I use this table in the formula below everything works fine.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;filtered production test = 
sumx(
    filter(
        capacity_production_by_plant,
        capacity_production_by_plant[Country] in
        values(top_10_country_list_alternative[Country])
        ),
        capacity_production_by_plant[production]
)&lt;/LI-CODE&gt;&lt;P&gt;However, I am unable to integrate to the two formulas together so that I do not need to create the additional table.&amp;nbsp; The code below does not work.&amp;nbsp; I get an error 'The values function expects a column reference expression or a table reference expression for argument '1''&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;filtered production test = 
var country_list =
topn(
    10,
    values(capacity_production_by_plant[Country]),
    calculate(sum(capacity_production_by_plant[production]),
    year(capacity_production_by_plant[year]) = 2023)
    )
    return
sumx(
    filter(
        capacity_production_by_plant,
        capacity_production_by_plant[Country] in
        values(country_list)
        ),
        capacity_production_by_plant[production]
)&lt;/LI-CODE&gt;&lt;P&gt;How do I go about integrating these two functions so I do not need to create a separate table?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2023 14:06:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Values-function-works-with-separate-table-but-not-within-same/m-p/3336666#M125146</guid>
      <dc:creator>theaddies</dc:creator>
      <dc:date>2023-07-18T14:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: Values function works with separate table but not within same function</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Values-function-works-with-separate-table-but-not-within-same/m-p/3336680#M125148</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am not sure how your datamodel looks like, but please try something like below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;filtered production test =
VAR country_list =
    SUMMARIZE (
        TOPN (
            10,
            ALL ( capacity_production_by_plant[Country] ),
            CALCULATE (
                SUM ( capacity_production_by_plant[production] ),
                YEAR ( capacity_production_by_plant[year] ) = 2023
            )
        ),
        capacity_production_by_plant[Country]
    )
RETURN
    SUMX (
        FILTER (
            capacity_production_by_plant,
            capacity_production_by_plant[Country] IN country_list
        ),
        capacity_production_by_plant[production]
    )
&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 18 Jul 2023 14:11:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Values-function-works-with-separate-table-but-not-within-same/m-p/3336680#M125148</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2023-07-18T14:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: Values function works with separate table but not within same function</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Values-function-works-with-separate-table-but-not-within-same/m-p/3336708#M125150</link>
      <description>&lt;P&gt;I don't get an error from this but it returns the sum of all production for the specfic year ignoring the top_10_country_list.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2023 14:19:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Values-function-works-with-separate-table-but-not-within-same/m-p/3336708#M125150</guid>
      <dc:creator>theaddies</dc:creator>
      <dc:date>2023-07-18T14:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: Values function works with separate table but not within same function</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Values-function-works-with-separate-table-but-not-within-same/m-p/3336749#M125152</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thank you for your message.&lt;/P&gt;
&lt;P&gt;Could you please share your sample pbix file's link?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2023 14:39:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Values-function-works-with-separate-table-but-not-within-same/m-p/3336749#M125152</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2023-07-18T14:39:54Z</dc:date>
    </item>
  </channel>
</rss>

