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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
gvg
Post Prodigy
Post Prodigy

How to get value from a column with unknown name

Hello folks,

 

Could you help me understand, how do I get value from a column when I do not know its name ? For example


myTable[Column5]     -  returns the value in Column5. 

 

How do I return value from the column if I do not know its name? I only know that it is the 5th column in  myTable?

Thanks!

1 ACCEPTED SOLUTION

If you are using Table.AddColumn, there is a very simple solution for this.

Put following in a custom column

= Record.ToList(_){4}

View solution in original post

6 REPLIES 6
gvg
Post Prodigy
Post Prodigy

Yep, this is what I was looking for. Thank you !

Vijay_A_Verma
Super User
Super User

myTable[Column5]  would return a list of values from Column5.

Equivalent expression would be (Since PQ is 0 indexed, hence 4 is used in place of 5 below)

Table.Column(myTable,Table.ColumnNames(myTable){4})

Thanks @Vijay_A_Verma , I will experiment with this. I actually need to return not a list, but single value from a corresponding row.

The just use the index of that. Hence, if you need 7th row's value then use an index of 6 like below

Table.Column(myTable,Table.ColumnNames(myTable){4}){6}

I must be missing something, but I try this and it does not work as expected:

= Table.AddColumn(Source, "Custom", each Table.ColumnNames(Source) {4} )

 

I would expect this to return a corresponding row value from column 5 .

If you are using Table.AddColumn, there is a very simple solution for this.

Put following in a custom column

= Record.ToList(_){4}

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors