Forum Discussion
Test calculated column as query in smaller table with SELECTEDTABLE
- Anonymous3 years ago
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.
- Anonymous3 years ago
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.
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.
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.
- JoachimSA3 years ago
Helper II
yes I did, works great 🙂