Forum Discussion
scott_od
3 years agoFrequent Visitor
Complex comparison of two excel files
I'm looking for some help please with this scenario which is too complex for me to resolve with my power query knowledge. Scenario I have 2 tables: - tabel 1 contains a list of items ordered by ...
- 3 years ago
I've managed to resolve this now, I'm not sure it's the most elegant or efficient solution, but it gives the result I was looking for:
- Load both Table 1 and Table 2 into Power Query.
- Add 'Key' column to both Table 1 and Table 2 ('Week'-'Item')
- New Query 'Table 3' based on Table 1
- Group by 'Key' (Sum 'Ordered')
- Merge Table 1 and Table 2 using 'Key'
- Expand merged table with 'Received'
- Add a custom column "Status' with the following formula:
- if [Received] = [Ordered] then "Correct amount"
- else if [Received] > [Ordered] then "More items"
- else if [Received] < [Ordered] then "Less items"
- else "Not related"
- Merge Table 1 and Table 3 using 'Key'
- Expand merged table with 'Received' and 'Status'
rubayatyasmin
Community Champion
3 years agoHi, scott_od
follow the steps
- Load both Table 1 and Table 2 into Power Query.
- Merge the tables based on the "Item" column.
- Expand the merged table to include "Customer" and "Ordered" columns.
- Add a custom column with the following formula:
- `if [Received] = [Ordered] then "Correct amount"
- `else if [Received] > [Ordered] then "More items"
- `else if [Received] < [Ordered] then "Less items"
- else "Not related"
- Remove unnecessary columns.
- Close & Load the modified Table 2 back into Excel.
adjust the logic with your exact value
scott_od
3 years agoFrequent Visitor
thanks for your suggestion, but the out does not provide the correct result, as it seems to duplicate items & weeks:
I tried adapting your suggestion & doing the merge based on "item" and "week" but in that scenario the results are incorrect for those orders where the total received amount is higher than the individual order, when in fact the total received amount is not enough to cover the item orders for that week