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.
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!
Solved! Go to Solution.
If you are using Table.AddColumn, there is a very simple solution for this.
Put following in a custom column
= Record.ToList(_){4}
Yep, this is what I was looking for. Thank you !
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}
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.