Forum Discussion
Add new calculated column with values from 2 tables (Power Query)
- 4 years ago
Hi Anonymous ,
Try adding this as a new custom column in Table2:
let currentName = [Name], meters = Table.SelectRows(Table1, each [Name] = currentName){0}[Produced Meters] in meters / [Run Time]This gives me the following output:
Pete
It's certainly possible to do this in one step (see BA_Pete's answer) but you should be aware that such a solution is less efficient than a multi-step approach of merging in the column and then dividing.
Merge-then-divide should be a linear complexity O(N) whereas an unoptimized lookup-then-divide is likely quadratic complexity O(N2). If your dataset is large this can make a huge difference.
AlexisOlson is correct.
I've done the solution as requested as an excercise but, if it was up to me, I'd relate both tables in the data model to a Name dimension table and do it with measures.
Pete
- Anonymous4 years agoNot applicable
I know you already helped me, but could you show me with this example how this would be done?
I've been working mainly in the Power Query since I don't have much familiarity with DAX and it still kind of confuses me.
Thanks!