<?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: How to use the non base table (custom table) columns? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-the-non-base-table-custom-table-columns/m-p/4288591#M170206</link>
    <description>&lt;P&gt;There's a couple of issues here. I'll address them in no particular order.&lt;/P&gt;
&lt;P&gt;Never use SUMMARIZE to create calculated columns. Use SUMMARIZE for grouping, but if you need to create calculated columns then use ADDCOLUMNS to do that part.&lt;/P&gt;
&lt;P&gt;You can't use SUMMARIZE on table variables, only on tables which are part of the model. If you want to do grouping of non-model tables, you can use GROUPBY with the CURRENTGROUP function. You could rewrite your code like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;EVALUATE
VAR TableVar =
    DATATABLE (
        "Name", STRING,
        "Region", STRING,
        "aColumn", DOUBLE,
        {
            { " User1", "East", 1.0 },
            { " User2", "East", 1.5 },
            { " User3", "West", 1.6 },
            { " User4", "West", 0.7 },
            { " User4", "East", 3.1 }
        }
    )
RETURN
    GROUPBY ( TableVar, "Total", SUMX ( CURRENTGROUP (), [aColumn] ) )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Nov 2024 09:28:21 GMT</pubDate>
    <dc:creator>johnt75</dc:creator>
    <dc:date>2024-11-18T09:28:21Z</dc:date>
    <item>
      <title>How to use the non base table (custom table) columns?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-the-non-base-table-custom-table-columns/m-p/4286386#M170124</link>
      <description>&lt;P&gt;I found this example in the forum. It was posted in 2018.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Measure 2 = 
VAR TableVar =
    ADDCOLUMNS(
        SUMMARIZE (
            'Product'
            ,'Product'[ProductKey]
            ,'Product'[Color]
        )
        ,"aColumn", 1
    )
RETURN
    SUMX(
        TableVar
        ,[aColumn]
    )&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It was working in 2018 but not working now. The "[aColumn]" cannot be resolved by DAX becaue TableVar is not a base table (any table defined in Data Model). Is any workaround available except creating the custom table in data model?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 16:22:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-the-non-base-table-custom-table-columns/m-p/4286386#M170124</guid>
      <dc:creator>tchiang7</dc:creator>
      <dc:date>2024-11-15T16:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the non base table (custom table) columns?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-the-non-base-table-custom-table-columns/m-p/4286405#M170126</link>
      <description>&lt;P&gt;That should still work. Can you post the code of the actual measure you're having trouble with ?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 16:37:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-the-non-base-table-custom-table-columns/m-p/4286405#M170126</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2024-11-15T16:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the non base table (custom table) columns?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-the-non-base-table-custom-table-columns/m-p/4286442#M170128</link>
      <description>&lt;P&gt;My usecase is using NATURALLEFTOUTERJOIN() to join two tables together, and apply SUMMARIZE with SUM() function. My problem is DAX won't recognize any column name included in the result table. Therefore the syntax of "my table"[column name] will not work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 17:15:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-the-non-base-table-custom-table-columns/m-p/4286442#M170128</guid>
      <dc:creator>tchiang7</dc:creator>
      <dc:date>2024-11-15T17:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the non base table (custom table) columns?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-the-non-base-table-custom-table-columns/m-p/4286596#M170133</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Here is the example:&lt;/P&gt;&lt;P&gt;EVALUATE&lt;BR /&gt;VAR TableVar =&lt;BR /&gt;&amp;nbsp; &amp;nbsp; DataTable("Name", STRING,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"Region", STRING,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"aColumn", DOUBLE&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;, {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{" User1","East", 1.0},&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{" User2","East", 1.5},&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{" User3","West", 1.6},&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{" User4","West", 0.7},&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{" User4","East", 3.1}&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp; &amp;nbsp; )&lt;BR /&gt;RETURN&lt;BR /&gt;SUMMARIZE(TableVar,"Total",&lt;BR /&gt;SUM('TableVar'[aColumn])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the error message:&lt;/P&gt;&lt;P&gt;Table variable 'TableVar' cannot be used in current context because a base table is expected.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 20:10:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-the-non-base-table-custom-table-columns/m-p/4286596#M170133</guid>
      <dc:creator>tchiang7</dc:creator>
      <dc:date>2024-11-15T20:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the non base table (custom table) columns?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-the-non-base-table-custom-table-columns/m-p/4287477#M170176</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="848461" data-lia-user-login="tchiang7" class="lia-mention lia-mention-user"&gt;tchiang7&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To resolve this issue without adding custom tables to your data model, you can adjust your DAX code to avoid passing table variables where base tables are expected. Here's how:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;1. Use Table Expressions Directly&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;Instead of storing the table in a variable, use the table expression directly within your function.&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;Measure 2 =
SUMX(
    ADDCOLUMNS(
        SUMMARIZE(
            'Product',
            'Product'[ProductKey],
            'Product'[Color]
        ),
        "aColumn", 1
    ),
    [aColumn]
)
&lt;/LI-CODE&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Explanation:&lt;/STRONG&gt;
&lt;UL&gt;
&lt;LI&gt;Removed the &lt;CODE&gt;VAR&lt;/CODE&gt; table variable.&lt;/LI&gt;
&lt;LI&gt;Passed the table expression directly into &lt;CODE&gt;SUMX&lt;/CODE&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;[aColumn]&lt;/CODE&gt; is now recognized within the context of &lt;CODE&gt;SUMX&lt;/CODE&gt;.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;HR /&gt;
&lt;H3&gt;&lt;STRONG&gt;2. Use Functions That Accept Table Expressions&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;Some functions, like &lt;CODE&gt;SUMMARIZECOLUMNS&lt;/CODE&gt;, accept table expressions and can work with table variables indirectly.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Example Using &lt;CODE&gt;SUMMARIZECOLUMNS&lt;/CODE&gt;:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;EVALUATE
SUMMARIZECOLUMNS(
    'Product'[Color],
    "Total",
    SUM('Product'[aColumn])
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt; Ensure that &lt;CODE&gt;'Product'[aColumn]&lt;/CODE&gt; exists in the base table or is defined within the context.&lt;/LI&gt;
&lt;/UL&gt;
&lt;HR /&gt;
&lt;H3&gt;&lt;STRONG&gt;3. Use &lt;CODE&gt;CURRENTGROUP()&lt;/CODE&gt; in &lt;CODE&gt;SUMMARIZE&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;When using &lt;CODE&gt;SUMMARIZE&lt;/CODE&gt;, you can leverage &lt;CODE&gt;CURRENTGROUP()&lt;/CODE&gt; to reference the current group in the row context.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Modified EVALUATE Statement:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;EVALUATE
SUMMARIZE(
    DATATABLE(
        "Name", STRING,
        "Region", STRING,
        "aColumn", DOUBLE,
        {
            {"User1", "East", 1.0},
            {"User2", "East", 1.5},
            {"User3", "West", 1.6},
            {"User4", "West", 0.7},
            {"User4", "East", 3.1}
        }
    ),
    [Region],
    "Total", SUMX(CURRENTGROUP(), [aColumn])
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Explanation:&lt;/STRONG&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;CODE&gt;CURRENTGROUP()&lt;/CODE&gt; refers to the subset of rows in the current group defined by &lt;CODE&gt;SUMMARIZE&lt;/CODE&gt;.&lt;/LI&gt;
&lt;LI&gt;This allows you to perform calculations on grouped data without referencing a table variable.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;HR /&gt;
&lt;H3&gt;&lt;STRONG&gt;4. Use &lt;CODE&gt;DEFINE&lt;/CODE&gt; in DAX Queries&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;When using &lt;CODE&gt;EVALUATE&lt;/CODE&gt; in tools like DAX Studio, you can define variables using &lt;CODE&gt;DEFINE&lt;/CODE&gt;:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;DEFINE
VAR TableVar =
    DATATABLE(
        "Name", STRING,
        "Region", STRING,
        "aColumn", DOUBLE,
        {
            {"User1", "East", 1.0},
            {"User2", "East", 1.5},
            {"User3", "West", 1.6},
            {"User4", "West", 0.7},
            {"User4", "East", 3.1}
        }
    )
EVALUATE
SUMMARIZE(
    TableVar,
    [Region],
    "Total", SUMX(CURRENTGROUP(), [aColumn])
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Explanation:&lt;/STRONG&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;CODE&gt;DEFINE&lt;/CODE&gt; allows you to declare variables accessible in the &lt;CODE&gt;EVALUATE&lt;/CODE&gt; statement.&lt;/LI&gt;
&lt;LI&gt;Ensures that the variable &lt;CODE&gt;TableVar&lt;/CODE&gt; is recognized in the query.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;HR /&gt;
&lt;P&gt;&lt;STRONG&gt;Key Takeaways:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Avoid Passing Table Variables to Functions Expecting Base Tables:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Functions like &lt;CODE&gt;SUMMARIZE&lt;/CODE&gt; and &lt;CODE&gt;SUM&lt;/CODE&gt; require base tables.&lt;/LI&gt;
&lt;LI&gt;Passing a table variable directly causes errors.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Use Table Expressions Inline:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Incorporate your table-generating expressions directly within your calculations.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Leverage &lt;CODE&gt;CURRENTGROUP()&lt;/CODE&gt; for Grouped Calculations:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Allows you to perform aggregations within &lt;CODE&gt;SUMMARIZE&lt;/CODE&gt; without referencing external variables.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Use &lt;CODE&gt;DEFINE&lt;/CODE&gt; for Variables in DAX Queries:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;In query contexts, &lt;CODE&gt;DEFINE&lt;/CODE&gt; makes variables available for use in &lt;CODE&gt;EVALUATE&lt;/CODE&gt;.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By adjusting your DAX code to align with the current requirements—avoiding the use of table variables where base tables are expected—you can achieve the desired calculations without adding custom tables to your data model.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Example Applying the Solution to Your Scenario:&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;-- Original measure adjusted to work without table variables
Measure 2 =
SUMX(
    ADDCOLUMNS(
        SUMMARIZE(
            'Product',
            'Product'[ProductKey],
            'Product'[Color]
        ),
        "aColumn", 1
    ),
    [aColumn]
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This approach should resolve the errors and allow your measure to function correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post&lt;STRONG&gt; helps&lt;/STRONG&gt;, please consider &lt;STRONG&gt;accepting&lt;/STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;it as the solution&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Appreciate your Kudos!!&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.linkedin.com/in/vahid-dm/" target="_blank" rel="noopener noreferrer"&gt;LinkedIn&lt;/A&gt;|&lt;A href="https://twitter.com/VahidDMcom" target="_blank" rel="noopener noreferrer"&gt;Twitter&lt;/A&gt;|&lt;A href="https://www.vahiddm.com/" target="_blank" rel="noopener noreferrer"&gt;Blog&amp;nbsp;&lt;/A&gt;|&lt;A href="https://www.youtube.com/@databis" target="_blank" rel="noopener noreferrer"&gt;YouTube&lt;/A&gt;&lt;A href="https://www.youtube.com/@databis" target="_blank" rel="noopener noreferrer"&gt;&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Nov 2024 07:06:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-the-non-base-table-custom-table-columns/m-p/4287477#M170176</guid>
      <dc:creator>VahidDM</dc:creator>
      <dc:date>2024-11-17T07:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the non base table (custom table) columns?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-the-non-base-table-custom-table-columns/m-p/4288591#M170206</link>
      <description>&lt;P&gt;There's a couple of issues here. I'll address them in no particular order.&lt;/P&gt;
&lt;P&gt;Never use SUMMARIZE to create calculated columns. Use SUMMARIZE for grouping, but if you need to create calculated columns then use ADDCOLUMNS to do that part.&lt;/P&gt;
&lt;P&gt;You can't use SUMMARIZE on table variables, only on tables which are part of the model. If you want to do grouping of non-model tables, you can use GROUPBY with the CURRENTGROUP function. You could rewrite your code like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;EVALUATE
VAR TableVar =
    DATATABLE (
        "Name", STRING,
        "Region", STRING,
        "aColumn", DOUBLE,
        {
            { " User1", "East", 1.0 },
            { " User2", "East", 1.5 },
            { " User3", "West", 1.6 },
            { " User4", "West", 0.7 },
            { " User4", "East", 3.1 }
        }
    )
RETURN
    GROUPBY ( TableVar, "Total", SUMX ( CURRENTGROUP (), [aColumn] ) )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 09:28:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-the-non-base-table-custom-table-columns/m-p/4288591#M170206</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2024-11-18T09:28:21Z</dc:date>
    </item>
  </channel>
</rss>

