Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Adding pivot columns in powerBI desktop using columns from different tables

Using PowerBI Desktop, I imported the following tables:

Table name: inventory
columns:

    item_code
    warehouse_code
    quantity

 

Table name: warehouses
columns:

    item_code
    location

 

The possibilities for location are:

    headquarters
    east_coast

 

What I would like to, is to have pivot columns, added to the inventory table, using the names in the location column of the warehouses table, and values from the quantity column of the inventory table. 

 

Any ideas how to do this?

5 Replies

  • Anonymous , you can join inventory with other table and use them should be 1 to Many with the inventory at many side.

     

    You should be able to that.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      They are already joined at the item_code level and it's a 1-1 join. I am not sure what you mean one to many

  • v-juanli-msft's avatar
    v-juanli-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous 

    Would you like to create result as below:

    If so, please merge query, expand column, then pivot column

    Best Regards
    Maggie
    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      So, you're suggesting I merge the column from one table into the orther table, and now that they're both in the same table, do the pivot. Yes, I'm aware that I can do that.

       

      Does this mean that it;'s not possible to do a pivot directly using a column from one table and one from another table?

      • v-juanli-msft's avatar
        v-juanli-msft
        Icon for Community Support rankCommunity Support

        Hi Anonymous 

        I'm afraid it is impossible to pivot columns from another table directly.

         

        Best Regards

        Maggie