cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Regular Visitor

## Is it possible to add multiple columns with DAX

Instead of adding columns one at a time using dax is it possible to add multiple columns in one go?  I can break the code up below to add one column at a time and it works, but when I try to combine it into one dax statement it doesn't.

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()
)
1 ACCEPTED SOLUTION
Community Support

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 =
'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.

3 REPLIES 3
Community Support

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 =
'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.

Regular Visitor

Makes sense! thank you 🙂

Super User

Not sure what you mean,

but u can use addcolumns function in dax to add as many as you want

Announcements

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

#### Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

#### Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors