Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
I found this example in the forum. It was posted in 2018.
Measure 2 =
VAR TableVar =
ADDCOLUMNS(
SUMMARIZE (
'Product'
,'Product'[ProductKey]
,'Product'[Color]
)
,"aColumn", 1
)
RETURN
SUMX(
TableVar
,[aColumn]
)
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?
Solved! Go to Solution.
Hi @tchiang7
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:
Instead of storing the table in a variable, use the table expression directly within your function.
Measure 2 =
SUMX(
ADDCOLUMNS(
SUMMARIZE(
'Product',
'Product'[ProductKey],
'Product'[Color]
),
"aColumn", 1
),
[aColumn]
)
VAR table variable.SUMX.[aColumn] is now recognized within the context of SUMX.Some functions, like SUMMARIZECOLUMNS, accept table expressions and can work with table variables indirectly.
Example Using SUMMARIZECOLUMNS:
EVALUATE
SUMMARIZECOLUMNS(
'Product'[Color],
"Total",
SUM('Product'[aColumn])
)
'Product'[aColumn] exists in the base table or is defined within the context.CURRENTGROUP() in SUMMARIZEWhen using SUMMARIZE, you can leverage CURRENTGROUP() to reference the current group in the row context.
Modified EVALUATE Statement:
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])
)
CURRENTGROUP() refers to the subset of rows in the current group defined by SUMMARIZE.DEFINE in DAX QueriesWhen using EVALUATE in tools like DAX Studio, you can define variables using DEFINE:
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])
)
DEFINE allows you to declare variables accessible in the EVALUATE statement.TableVar is recognized in the query.Key Takeaways:
Avoid Passing Table Variables to Functions Expecting Base Tables:
SUMMARIZE and SUM require base tables.Use Table Expressions Inline:
Leverage CURRENTGROUP() for Grouped Calculations:
SUMMARIZE without referencing external variables.Use DEFINE for Variables in DAX Queries:
DEFINE makes variables available for use in EVALUATE.
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.
Example Applying the Solution to Your Scenario:
-- Original measure adjusted to work without table variables
Measure 2 =
SUMX(
ADDCOLUMNS(
SUMMARIZE(
'Product',
'Product'[ProductKey],
'Product'[Color]
),
"aColumn", 1
),
[aColumn]
)
This approach should resolve the errors and allow your measure to function correctly.
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn|Twitter|Blog |YouTube
Hi @tchiang7
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:
Instead of storing the table in a variable, use the table expression directly within your function.
Measure 2 =
SUMX(
ADDCOLUMNS(
SUMMARIZE(
'Product',
'Product'[ProductKey],
'Product'[Color]
),
"aColumn", 1
),
[aColumn]
)
VAR table variable.SUMX.[aColumn] is now recognized within the context of SUMX.Some functions, like SUMMARIZECOLUMNS, accept table expressions and can work with table variables indirectly.
Example Using SUMMARIZECOLUMNS:
EVALUATE
SUMMARIZECOLUMNS(
'Product'[Color],
"Total",
SUM('Product'[aColumn])
)
'Product'[aColumn] exists in the base table or is defined within the context.CURRENTGROUP() in SUMMARIZEWhen using SUMMARIZE, you can leverage CURRENTGROUP() to reference the current group in the row context.
Modified EVALUATE Statement:
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])
)
CURRENTGROUP() refers to the subset of rows in the current group defined by SUMMARIZE.DEFINE in DAX QueriesWhen using EVALUATE in tools like DAX Studio, you can define variables using DEFINE:
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])
)
DEFINE allows you to declare variables accessible in the EVALUATE statement.TableVar is recognized in the query.Key Takeaways:
Avoid Passing Table Variables to Functions Expecting Base Tables:
SUMMARIZE and SUM require base tables.Use Table Expressions Inline:
Leverage CURRENTGROUP() for Grouped Calculations:
SUMMARIZE without referencing external variables.Use DEFINE for Variables in DAX Queries:
DEFINE makes variables available for use in EVALUATE.
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.
Example Applying the Solution to Your Scenario:
-- Original measure adjusted to work without table variables
Measure 2 =
SUMX(
ADDCOLUMNS(
SUMMARIZE(
'Product',
'Product'[ProductKey],
'Product'[Color]
),
"aColumn", 1
),
[aColumn]
)
This approach should resolve the errors and allow your measure to function correctly.
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn|Twitter|Blog |YouTube
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.
That should still work. Can you post the code of the actual measure you're having trouble with ?
Thank you.
Here is the example:
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
SUMMARIZE(TableVar,"Total",
SUM('TableVar'[aColumn])
)
This is the error message:
Table variable 'TableVar' cannot be used in current context because a base table is expected.
There's a couple of issues here. I'll address them in no particular order.
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.
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
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] ) )
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 3 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 13 | |
| 9 | |
| 8 | |
| 8 | |
| 7 |