Forum Discussion
marcelmunk
4 years agoFrequent Visitor
Retrieve value from same row based on column name in column
Hi, Pretty basic question (I believe) as I'm a beginner in Power BI and still on my basics on DAX. I have a Table which has the Product Name and many properties I want to add a new ...
- 4 years ago
Here's an alternative solution that reads the record itself:
= Table.AddColumn(Source, "Value", each Record.FieldOrDefault(_,[Desired Property], null))
marcelmunk
4 years agoFrequent Visitor
Thanks for your answer, Vijay_A_Verma
The Prop1..PropN are just an example, unfortunatey. They actually have names such as Discipline, Nominal_Diameter, etc. It was just a way to simplify the understanding.
Is it possible to write a formula that would look up all the column names and match for the results?
Thanks again
Vijay_A_Verma
4 years agoMost Valuable Professional
In this case, use below formula
= try Table.Column(Source,[Desired Property]){List.PositionOf(Table.ColumnNames(Source),[Desired Property])} otherwise null- marcelmunk4 years agoFrequent Visitor
- marcelmunk4 years agoFrequent Visitor
Looking closer, the result for first row, 'Smooth' property is on the second row, not first. And the result 'Green' should be for the first row, not second.
Somehow it's messing up rows and colums.- Vijay_A_Verma4 years agoMost Valuable Professional
Then use this
I misunderstood your requirement. Use this
= Table.Column(Source,[Desired Property]){List.PositionOf(Source[Desired Property],[Desired Property])}