Forum Discussion
acerNZ
Helper III
5 years agoCan I dynamically change the joins
Hi Experts I have to present details of 1. Data in sheet1 which is different to sheet 2 2. Data in sheet 1 same as sheet 2 3. Data in Sheet 2 not in Sheet 1 The way, I think is to can use...
- 5 years ago
Hi acerNZ
I think what's happening is that my queries were written in Excel because I assumed (my fault) that you were going to do this in Excel. So the query is trying to load the tables from the Current Workbook.
To use this in PBI the query needs to change a little to load the tables from an external workbook.
Replace the code in Sheet1 query with this.
NOTE make sure to change the path to the Excel workbook in this code, in the Source step at the top
let Source = Excel.Workbook(File.Contents("D:\temp\AcerNZ.xlsx"), null, true), Source1 = Source{[Item="Table1",Kind="Table"]}[Data], Source2 = Source{[Item="Table2",Kind="Table"]}[Data], Join.LeftAnti = Table.NestedJoin(Source1, {"ID"}, Source2, {"ID"}, "Join1", JoinKind.LeftAnti), #"Removed Columns1" = Table.RemoveColumns(Join.LeftAnti,{"Join1"}), Join.Inner = Table.NestedJoin(Source1, {"ID"}, Source2, {"ID"}, "Join1", JoinKind.Inner), #"Removed Columns" = Table.RemoveColumns(Join.Inner,{"Join1"}), Join.RightAnti = Table.NestedJoin(Source1, {"ID"}, Source2, {"ID"}, "Join1", JoinKind.RightAnti), Join.LeftAnti2 = Table.NestedJoin(Source2, {"ID"}, Source1, {"ID"}, "Join1", JoinKind.LeftAnti), #"Removed Columns2" = Table.RemoveColumns(Join.LeftAnti2,{"Join1"}), Result = {Join.LeftAnti, Join.Inner, Join.LeftAnti2} in ResultPhil
acerNZ
Helper III
5 years agoHey PhilipTreacy
Thank you very much. It worked when I clicked on each table, I could see the result. this is exactly what I was looking for. instead of creating 3 copies with different joins.
Best Regards