Forum Discussion
Merging two tables
- 1 year ago
Hi Mangnuel
In this case, you should be able to use “Merge Queries as New”.
In Power Query:
- Select your Table1 and in the Combine section of the Home menu, select Merge Queries As New.
- In the Merge window, select Table 2 as the second table. Select the common columns in each table ( Date and Asset-Code ) using the CTRL key, and hit OK.
- In the Merge1 table, expand the Table 2 column, and select ONLY Yield Utility and hit OK.
- In the new Yield Utility column, filter out the null values.
Let me know if you have any questions.
- Anonymous1 year ago
Thanks for the reply from tharunkumarRTK and gmsamborn , please allow me to provide another insight:
Hi Mangnuel ,Here are the steps you can follow:
1. Create calculated table.
Table = ADDCOLUMNS( 'Table 1', "Yield Utility", SUMX( FILTER(ALL('Table 2'), 'Table 2'[Date]=EARLIER('Table 1'[Date])&& 'Table 1'[Asset-Code]=EARLIER('Table 1'[Asset-Code])),[Yield Utility]))2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi gmsamborn
it works perfectly, thanks a lot.
Everyhting looks good!
But one further questions.
Is it also possible within Power Bi by using DAX-Formulars?
Thanks again
Though I wont recommend creating DAX cacculated tables and columns, I am providing some possibilities for education purposes.
Yes you can do the same with DAX.
1. create a caculated column in both Table 1 and Table 2. The column definition should be, a concatenation of YearMonth column and Asset-Code column. (Ex: Jan-24 | A).
(Lets assume you named your new column as a Join_Key)
2. You can use DAX join functions perform the merge operation.
https://www.sqlbi.com/articles/using-join-functions-in-dax/
Please be informed, you can also merge tables with out creating a new calcualted column, I am suggesting you to do so as it would be simpler to understand. The join functions in DAX can also be used without relationships, but in that case, the join condition is applied to columns with the same data lineage regardless of the column name or the same name and no data lineage.
https://www.sqlbi.com/articles/replacing-relationships-with-join-functions-in-dax
Need a Power BI Consultation? Hire me on Upwork
Connect on LinkedIn
|