Forum Discussion

pbsamar's avatar
pbsamar
Regular Visitor
2 years ago
Solved

How do I create Sankey Chart from two table data?

We have following two tables "Shop Transaction" and "Organization Tree".

Use PowerBI desktop to create a Sankey chart using these data.

 

Note that:

  • When a shop is added or a shop changes district, the start date changes in "Organization Tree".
  • Organization Tree’ has a hierarchy of Region> District> Shop. The Region is the root of the tree.

 

Shop Transaction

Organization Tree

 

Output Sankey data format

Output Sanky format

  • Step 0: I use these DATA Tables below. (I add some dammy data to 'Shop Transactions' table.)

     

     

    Step 1: I add a column to these 2 tables each.

     

     

    Step 2: I merge 2 tables.

    - Before -

    - After -

     

    Step 3: I sort 'Shop Transactions' table with 'shop no' column and 'date'column.

     

    Step 4: I fill down 'Parent' column.

     

     

     

3 Replies

  • Step 0: I use these DATA Tables below. (I add some dammy data to 'Shop Transactions' table.)

     

     

    Step 1: I add a column to these 2 tables each.

     

     

    Step 2: I merge 2 tables.

    - Before -

    - After -

     

    Step 3: I sort 'Shop Transactions' table with 'shop no' column and 'date'column.

     

    Step 4: I fill down 'Parent' column.

     

     

     

  • Hi pbsamar 

     

    Based on your desired result, it looks like a Decomposition Tree is more what you are after rather than a Sankey Diagram?

     

    Either way, there's no way to relate the Shops in the first table to the Districts.  How do you know which District the Shop1 and Shop21's belong to?

     

    Regards

     

    Phil

     

    • pbsamar's avatar
      pbsamar
      Regular Visitor

      Hi  PhilipTreacy 

       

      Based on 'date'  from "Shop Transactions" and 'start date' from "Organization Tree" , a  'region' column need to be

      created, which should look like :

       

      dateshop nochecksale amountRegion
      2-Jun-24shop1110district1
      3-Jun-24shop1220district1
      4-Jun-24shop1330district1
      5-Jun-24shop1440district2
      6-Jun-24shop1550district2
      7-Jun-24shop1660district2
      2-Jun-24shop2110district1
      4-Jun-24shop2330district1
      5-Jun-24shop2440district1
      6-Jun-24shop2550district1
      7-Jun-24shop2660district1
      2-Jun-24shop2111district2
      3-Jun-24shop2122district2
      4-Jun-24shop2133district2
      5-Jun-24shop2144district1
      6-Jun-24shop2155district1
      7-Jun-24shop2166district1
      3-Jun-24shop22220district2
      4-Jun-24shop22330district2
      5-Jun-24shop22440district2
      6-Jun-24shop22550district2
      7-Jun-24shop22660district2

       

       

      Regards,

       

      pbsamar