Forum Discussion
Is it possible to add multiple columns with DAX
- Anonymous2 years ago
Hi Anonymous
If you want to add multiple columns at one time, you need to use calculated table, because it will return multiple columns, you cannot create them directly at the existed table. you can refer to the following sample.
Create a calculated table
Table2 = ADDCOLUMNS ( 'Table', "Alice", SWITCH ( TRUE (), 'Table'[Name] = "Alice", "Alice", 'Table'[Name] = "Bob", UNICHAR ( 8203 ), 'Table'[Name] = "Carol", REPT ( UNICHAR ( 8203 ), 2 ), BLANK () ), "Bob", SWITCH ( TRUE (), 'Table'[Name] = "Alice", UNICHAR ( 8203 ), 'Table'[Name] = "Bob", "Bob", 'Table'[Name] = "Carol", REPT ( UNICHAR ( 8203 ), 2 ), BLANK () ), "Carol", SWITCH ( TRUE (), 'Table'[Name] = "Alice", REPT ( UNICHAR ( 8203 ), 2 ), 'Table'[Name] = "Bob", UNICHAR ( 8203 ), 'Table'[Name] = "Carol", "Carol", BLANK () ) )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 Anonymous
If you want to add multiple columns at one time, you need to use calculated table, because it will return multiple columns, you cannot create them directly at the existed table. you can refer to the following sample.
Create a calculated table
Table2 =
ADDCOLUMNS (
'Table',
"Alice",
SWITCH (
TRUE (),
'Table'[Name] = "Alice", "Alice",
'Table'[Name] = "Bob", UNICHAR ( 8203 ),
'Table'[Name] = "Carol", REPT ( UNICHAR ( 8203 ), 2 ),
BLANK ()
),
"Bob",
SWITCH (
TRUE (),
'Table'[Name] = "Alice", UNICHAR ( 8203 ),
'Table'[Name] = "Bob", "Bob",
'Table'[Name] = "Carol", REPT ( UNICHAR ( 8203 ), 2 ),
BLANK ()
),
"Carol",
SWITCH (
TRUE (),
'Table'[Name] = "Alice", REPT ( UNICHAR ( 8203 ), 2 ),
'Table'[Name] = "Bob", UNICHAR ( 8203 ),
'Table'[Name] = "Carol", "Carol",
BLANK ()
)
)
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.
Makes sense! thank you 🙂