Forum Discussion
Mark Differences Between 2 Table
- 7 years ago
In that case, you can select the relevant columns first from both tables using "SELECTCOLUMNS" function
Then apply the above procedure
i.e.
Calculated Table = VAR firstTable = SELECTCOLUMNS ( Table1, "ID", [ID], "Serial", [Serial], "Name", [Name] ) VAR SecondTable = SELECTCOLUMNS ( Table2, "ID", [ID], "Serial", [Serial], "Name", [Name] ) VAR Common = INTERSECT ( firstTable, SecondTable ) VAR NotCommon = EXCEPT ( DISTINCT ( UNION ( firstTable, SecondTable ) ), Common ) RETURN UNION ( ADDCOLUMNS ( Common, "Unique", "No" ), ADDCOLUMNS ( NotCommon, "Unique", "Yes" ) )
Please could you copy paste some data with expected result
If you could copy paste like this....it will save me time in typing
| Customer | Date | Amount |
| Dave | 05-01-18 | 5 |
| Dave | 01-09-18 | 3 |
| Roy | 24-02-18 | 4 |
| Roy | 23-08-18 | 2 |
Hi Zubair_Muhammad , sorry, jugling with other routine just have chance to reply
So if we look at the table below, unique will only marked when serial is duplicating , despite the ID or Name is same . Kindly need your advise
| Table 1 | |||
| ID | Serial | Name | |
| A123 | XXX | John | |
| A123 | YYY | Anna | |
| B123 | ZZZ | John | |
| Table 2 | |||
| ID | Serial | Name | |
| A123 | XXX | John | |
| B123 | VVV | John | |
| C123 | QQQ | Marrie | |
| Expectation | |||
| ID | Serial | Name | Unique |
| A123 | XXX | John | No |
| A123 | YYY | Anna | Yes |
| B123 | ZZZ | John | Yes |
| A123 | XXX | John | No |
| B123 | VVV | John | Yes |
| C123 | QQQ | Marrie | Yes |
- v-yulgu-msft7 years agoMicrosoft Employee
Hi __zhe,
Please new a calculated table and add a calculated column in it.
Table_3 = UNION(Table_1,Table_2) Unique = IF(CALCULATE(COUNT(Table_3[Serial ]),ALLEXCEPT(Table_3,Table_3[Serial ]))>1,"No","Yes")
Best regards,
Yuliana Gu
- v-yulgu-msft7 years agoMicrosoft Employee
Hi __zhe,
table 1 & 2 have different structure, forgotten to mention in the example and also how to nood include null valueAs Zubair_Muhammad mentioned in previous reply, you can use SELECTCOLUMNS to deal with this problem.
Regards,
Yuliana Gu
- __zhe7 years agoFrequent Visitor
Hi v-yulgu-msft table 1 & 2 have different structure, forgotten to mention in the example and also how to nood include null value