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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
BlueCatOwner01
New Member

How to look up a value by column name - HALP

Hi all, 

 

I am trying to create a new column which would look up the value in another column in the same row based on the value in another column where each row is a column name. 

 

I know sounds confusing right? Hope this visual helps

Column AColumn BColumn CColumn DColumn EColumn FColumn NamesValue Look Up
111111Column A 
222222Column C 
333333Column F 
444444Column D 
555555Column B 

 

I want to populate values in the "Value Look Up" Column by looking up the value in the same row based on the column name value found in the "Column Names" Column.

 

The current DAX code I am trying to write is something along the lines of:

Value Look Up = 'Table1'['Table1'[Column Names]]

 

But as you can imagine, Power BI is not having it.

 

Any help would be apprecaited.

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

This would be easiest to solve with Power Query

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column A", Int64.Type}, {"Column B", Int64.Type}, {"Column C", Int64.Type}, {"Column D", Int64.Type}, {"Column E", Int64.Type}, {"Column F", Int64.Type}, {"Column Names", type text}}),
    #"Added Custom1" = Table.AddColumn(#"Changed Type", "Custom.1", each Record.ToList(_){List.PositionOf(Table.ColumnNames(#"Changed Type"),[Column Names])})
in
    #"Added Custom1"

Hope this helps.

Ashish_Mathur_0-1723868867146.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

This would be easiest to solve with Power Query

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column A", Int64.Type}, {"Column B", Int64.Type}, {"Column C", Int64.Type}, {"Column D", Int64.Type}, {"Column E", Int64.Type}, {"Column F", Int64.Type}, {"Column Names", type text}}),
    #"Added Custom1" = Table.AddColumn(#"Changed Type", "Custom.1", each Record.ToList(_){List.PositionOf(Table.ColumnNames(#"Changed Type"),[Column Names])})
in
    #"Added Custom1"

Hope this helps.

Ashish_Mathur_0-1723868867146.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
mostho
Helper II
Helper II

you could use the DAX-Function SWITCH

Could you give me an example please?

hello @BlueCatOwner01 

 

using SWITCH to get this result

Value Look Up =
SWITCH(
    TRUE(),
    'Table'[Column Names]="Column A",'Table'[Column A],
    'Table'[Column Names]="Column B",'Table'[Column B],
    'Table'[Column Names]="Column C",'Table'[Column C],
    'Table'[Column Names]="Column D",'Table'[Column D],
    'Table'[Column Names]="Column E",'Table'[Column E],
    'Table'[Column Names]="Column F",'Table'[Column F]
)

Irwan_0-1723853421837.png

 

However, the problem is when you have a lot of columns, then you need to type each of them.

If you have a lot of columns, maybe you might want to unpivot them first to process the data.
Unpivot is for combining those columns into one column (processing one column is much easier than multiple column), but thats depend on your goal.

 

Hope this will help.

Thank you.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.

Top Solution Authors
Top Kudoed Authors