Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All
How do I merge Table 1 & 2 with same column heading (in load script or in straight table)
Table 1. (Table Name : Product)
OrderId | ProductName | ProductType | Price |
---|---|---|---|
1 | Coke | Drink | 2.50 |
2 | Sandwich | Food | 7.00 |
3 | Water | Drink | 3.50 |
Table 2.(Table Name : Charge)
OrderId | ChargeName | Charge |
---|---|---|
1 | Service Fee | 2.00 |
1 | Reservation Fee | 5.00 |
2 | Service Fee | 2.00 |
3 | Service Fee | 2.00 |
I want to merge the Charge Name & Product Name as one called 'Cost Name' and Price and Charge as 'Cost'
So the final table should look like this.
OrderId | Cost Name | Cost |
---|---|---|
1 | Coke | 23 |
1 | Service Fee | 2.00 |
1 | Reservation Fee | 5.00 |
2 | Sandwich | 7.00 |
2 | Service Fee | 2.00 |
3 | Water | 3.50 |
3 | Service Fee | 2.00 |
To do it in the Script perform the following steps:
1. Load your first set of data, but name it as the final Cost Table.
2. Rename each column as if it is the final Cost Table.
3. When loading the next set of data do NOT give it a filename, but just load it which will append it to the Cost Table created above.
4. Make sure to name each column identical to those in step 2 above.
CostTable:
LOAD OrderId,
[Product Name] as CostName,
Price as Cost
FROM
(
LOAD OrderId,
[Charge Name] as CostName,
Charge as Cost
FROM
(
Sheet1 of Combine.xlsx:
Sheet2 of Combine.xlsx:
Is this what you need?
- Stan
May be as below: