Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Relationships between groups

Hey, I have a data set looking like screenshot following, but I have met a wall, and I know this is simple cut cannot conceptualise this:

In my set, an order can come from several sources: adwords, mail, blogger, call centre (cc). It can also have several sources (mainly adwords and blogger, or adwords and cc).

How can I create a relationship between a table I created (dim_team, on the left) and fact_order on the right, so that when I select a team, it will filter only orders made by that team (or shared with other teams).

 

Also, which visualisation do you recommend to show how mnay orders are shared between teams? I was hoping to use something like a Venn, rather than creating new conditional columns with permutations of sources.

 

 

  • Anonymous so you should unpivot the data by following these steps:

     

    Transform Data -> Select Order id and pK_Date columns -> Right click -> Unpivot other columns

     

    It will add two columns, attribute and value, rename as you want it, close, and apply.

     

    Now set the relationship from the dim table to the attribute column in the fact table and that's it. Now you should be able to slicer the fact table from the dim table

7 Replies

  • Anonymous so you should unpivot the data by following these steps:

     

    Transform Data -> Select Order id and pK_Date columns -> Right click -> Unpivot other columns

     

    It will add two columns, attribute and value, rename as you want it, close, and apply.

     

    Now set the relationship from the dim table to the attribute column in the fact table and that's it. Now you should be able to slicer the fact table from the dim table

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks parry2k , i tried that and this would create duplicate entries for orders which have more than channel assigned to them. Is there a way to avoid that?

    • Anonymous's avatar
      Anonymous
      Not applicable

      hello parry2k  i think i managed to unpivot the tables without duplication of the orders, but how do I now use it so that I can select a channel and the table will filter based on which channel I want? channels are in different columns:

       

  • Anonymous not sure what is the shape of your fact tables. Can you share? It should be unpivoted if it is not already.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hey parry2k , it looks just like that, plus some columns. the flags from_adwords, from_blogger etc are a result of SQL modifications at the source (in power query I put a sql script)

       

      OrderIDPK_Datefrom_adwordsfrom_bloggerfrom_ccfrom_mailfrom_organic 
      1189922202/06/2024 00:0010010 
      1189924302/06/2024 00:0010110 
      1189924502/06/2024 00:0010010 
      1189977702/06/2024 00:0010010 
      1189980602/06/2024 00:0010010 
      1189987302/06/2024 00:0010010 
      1189987802/06/2024 00:0010010 
      1189988402/06/2024 00:0010000 
      1189989802/06/2024 00:0010010 
      1189990302/06/2024 00:0010010 
      1189995602/06/2024 00:0010010 
      1189998902/06/2024 00:0010010 
      1189999502/06/2024 00:0000010 
      1190003602/06/2024 00:0010010 
      1190007202/06/2024 00:0010010

       

       

       

  •  how about this part? 

    Now set the relationship from the dim table to the attribute column in the fact table and that's it. Now you should be able to slicer the fact table from the dim table

     

    Anonymous

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, Anonymous  

    Thanks for parry2k's concern about this issue.

    parry2k's method is correct.


    Based on the dataset you provided, first you should hold Ctrl and do a multi-select of the OrderID and PK_Date columns in PowerQuery Editor:


    Then select Unpivoted other columns:

     

    And the result should look like this, not like your result:

    And then close&reply.

     

    Create a relationship between this table and your table dim_team:

     

     

    You can then add a Slicer for data filtering:

     

     

     

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
    Best Regards,
    Fen Ling,
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.