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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Dynamic Select Column via Variable DAX

Hi All,

 

is it possible to use a variable to select dynamically a column? Example

 

TABLE A

--------------------

NewColumn = 
var name_column = "Column" & (5+1)
return
---> Here I want to return the values of "Column6" (5+1), based on variable "name_column" who has been calculated dynamically <----


Thanks

1 ACCEPTED SOLUTION
sturlaws
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

 

Only way I can think of is to create a switch statement:

new column =
SWITCH ( 
yourCalculationValue, 
1, column1, 
2, column2, 
.
.
.
.
.
6, column6,
blank )

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

View solution in original post

1 REPLY 1
sturlaws
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

 

Only way I can think of is to create a switch statement:

new column =
SWITCH ( 
yourCalculationValue, 
1, column1, 
2, column2, 
.
.
.
.
.
6, column6,
blank )

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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