I have 2 data tables connected in my powerbi workbook. My objective is to replace a column data with a column data from another table in powerbi.
Below is the sample example.
Table 1:
| Customer | Action 1 | Action2 | ID |
|---|---|---|---|
| A | Open | InProg | 1001 |
| B | Closed | Sent | 1002 |
| B | On Hold | Waiting | 1003 |
Table 2:
| Customer | Action 1 | Action2 | ID |
|---|---|---|---|
| B | Open | InProg | 1002 |
| B | Closed | Sent | 1003 |
| B | On Hold | Waiting | 1004 |
Expected Output (Table 1 rows should replace with Table 2 matching rows based on Customer and ID columns):
| Customer | Action 1 | Action2 | Action3 |
|---|---|---|---|
| A | Open | InProg | 1001 |
| B | Open | InProg | 1002 |
| B | Closed | Sent | 1003 |



With the current specifications, I give you the following code:
Note, this has been tested in Excel (see the
Source=line). The script is picky about column name and works with your tables. Beware, you haveAction 1with a space andAction2, no space. This script needs aTable2defined.Note that the table expansion, after the Merge, doesn't preserve the order of the line, then the last action is a sort on ID.
Here, the idea is to get Action1 and Action2 from Table2 when available; and fallback to Table1 if not. This decision is on
AddAction1=andAddAction2=lines.