# Question about joining two tables

**Daniel Bouwmeester**Feb 10, 2019 10:56 PM

Hi everybody,

I have a question about joining two tables with data, eventually to be able to make a cost calculation for a production company for packed vegetables which produces bags of vegetables:

- In the example, they produce 1 type of vegetable in bags with different weights
- Some costs are the same for every weight: fixed costs per bag
- Some costs are related to the weight: variable costs per bag
- Also the amount of bags per box are related to the weight and thus the costs per unit for the box itself
- I have one table with fixed costs and one table with variable costs: the table with variable costs has got more columns
- By putting together with an 'Union' a dataset is created in which the value for 'Weight per unit' and 'Amount per box' is 'null' for the rows from table 1
- But the problem is: these costs are valid for all 'weight per unit's.
- If add a worksheet and put the weights in columns, the costs in rows, then I get one column 'Null' with the values of the fixed costs and several columns with the weights with the values of the variable costs
- How can I fix this? Is this possible within Tableau?

Thanks in advance for the reply!

**Table 1:** fixed costs > they are for all the products the same, however I want to be able to calculate a positive and negative scenario

PRODUCT CODE | SCENARIO | TYPE OF COST | CATEGORY OF COST | COST PER UNIT (EUR) |
---|---|---|---|---|

VEGETABLE01 | POSITIVE | Transport inbound | TRANSPORT | 0,0125 |

VEGETABLE01 | NEGATIVE | Transport inbound | TRANSPORT | 0,0150 |

VEGETABLE01 | POSITIVE | Cooling costs | STORAGE | 0,0100 |

VEGETABLE01 | NEGATIVE | Cooling costs | STORAGE | 0,0150 |

VEGETABLE01 | POSITIVE | Product label | PACKAGING | 0,0044 |

VEGETABLE01 | NEGATIVE | Product label | PACKAGING | 0,0085 |

**Table 2:** variable costs > they are different for each different bag (200g, 300g, 500g) because they are related to the weight. This influences not only the cost per unit, but also the amound of packagings which can be stored in a cardboard box. Also in this table, a positive and negative scenario is included.

PRODUCT CODE | WEIGHT PER UNIT (g) | SCENARIO | AMOUNT PER BOX | TYPE OF COST | CATEGORY OF COST | COST PER UNIT (EUR) |
---|---|---|---|---|---|---|

VEGETABLE01 | 200 | POSITIVE | 90 | Bag | PACKAGING | 0,0025 |

VEGETABLE01 | 200 | NEGATIVE | 90 | Bag | PACKAGING | 0,0028 |

VEGETABLE01 | 300 | POSITIVE | 60 | Bag | PACKAGING | 0,0045 |

VEGETABLE01 | 300 | NEGATIVE | 60 | Bag | PACKAGING | 0,0049 |

VEGETABLE01 | 500 | POSITIVE | 36 | Bag | PACKAGING | 0,0072 |

VEGETABLE01 | 500 | NEGATIVE | 36 | Bag | PACKAGING | 0,0078 |

VEGETABLE01 | 200 | POSITIVE | 90 | Box | PACKAGING | 0,0110 |

VEGETABLE01 | 200 | NEGATIVE | 90 | Box | PACKAGING | 0,0120 |

VEGETABLE01 | 300 | POSITIVE | 60 | Box | PACKAGING | 0,0142 |

VEGETABLE01 | 300 | NEGATIVE | 60 | Box | PACKAGING | 0,0153 |

VEGETABLE01 | 500 | POSITIVE | 36 | Box | PACKAGING | 0,0170 |

VEGETABLE01 | 500 | NEGATIVE | 36 | Box | PACKAGING | 0,0182 |