Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join 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.

Reply
JoachimSA
Helper II
Helper II

Test calculated column as query in smaller table with SELECTEDTABLE

Hi All,

 

I would really like to test some more complex calculated column in Dax Studio or Tabular Editor.

 

This calculated column depends on multiple other columns in the same table which is fairly wide and ha a lot of additional columns I do not need to see to test the logic og my calculated column.

So my Idea was to create a smaller test table as "playground" in Tabular Editor with the following Syntax:

 

VAR Playground = 
CALCULATETABLE(
        SELECTCOLUMNS(
            'Projects',
            "Needed Info 1", 'Projects'[Needed Info 1],
            "Needed Info 2", 'Projects'[Needed Info 2],
            "Needed Info 3", 'Projects'[Needed Info 3],
            
        ),
        'Projects'[Owner] = "John",
        'Projects'[Source] = "BWH"
    )

 

This allows me to Filter the Table to some relevant portion, make it a lot slimmer and still have the same grain as my original project table.

 

Now I would like to leverage the row context of the ADDCOLUMN() function to add my new calculated column for testing:

 

 

ADDCOLUMNS(
   Playground,
   "Test Calc Column",    'Projects'[Needed Info 1]
)

 

 

This results in an error an error saying that no singular value could be found for column "Needed Info 1" in table "Projects".

What am I getting wrong here ?

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @JoachimSA 

If you want to add a new column, you can only add the columns already in the current table, you can not add columns in another table, to add columns in other tables you need to use expressions such as sum(), calculate(), etc , please refer to the following link:

How to use AddColumns function in DAX and Power BI - RADACAD

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

Hi @JoachimSA 

Did you use "return", e.g

 

VAR Playground = 
CALCULATETABLE(
        SELECTCOLUMNS(
            'Projects',
            "Needed Info 1", 'Projects'[Needed Info 1],
            "Needed Info 2", 'Projects'[Needed Info 2],
            "Needed Info 3", 'Projects'[Needed Info 3],
            
        ),
        'Projects'[Owner] = "John",
        'Projects'[Source] = "BWH"
    )
return 
ADDCOLUMNS(
   Playground,
   "Test Calc Column",    [Needed Info 1])

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
JoachimSA
Helper II
Helper II

Hi,

 

it seems I got ist to work by adressing the selectedcolumns by their new name without the original table name in the front:

 

ADDCOLUMNS(
   Playground,
   "Test Calc Column",    [Needed Info 1]
)

 

 

If I had used a Summarizecolumns to create the Playground table I would have to use the full original column name it seems.

Anonymous
Not applicable

Hi @JoachimSA 

Did you use "return", e.g

 

VAR Playground = 
CALCULATETABLE(
        SELECTCOLUMNS(
            'Projects',
            "Needed Info 1", 'Projects'[Needed Info 1],
            "Needed Info 2", 'Projects'[Needed Info 2],
            "Needed Info 3", 'Projects'[Needed Info 3],
            
        ),
        'Projects'[Owner] = "John",
        'Projects'[Source] = "BWH"
    )
return 
ADDCOLUMNS(
   Playground,
   "Test Calc Column",    [Needed Info 1])

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

yes I did, works great 🙂

Anonymous
Not applicable

Hi @JoachimSA 

If you want to add a new column, you can only add the columns already in the current table, you can not add columns in another table, to add columns in other tables you need to use expressions such as sum(), calculate(), etc , please refer to the following link:

How to use AddColumns function in DAX and Power BI - RADACAD

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.