Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Connecting 2 tables question

Hi,

 

i'm hoping this is a straightworward question..

 

I have data across 2 tables and need to track by products/ ALL suppliers etc. My issue is that i have 2 supplier columns for different parts of each product. see tables example below. 

How should I be shaping the data? Do i need to duplcate the first table multiple times or something..etc? Hopefully that's clear..  

 

ProductSupplier1Supplier2Date Due
ApplesH12G2301/01/2022
OrangesH12F3402/01/2022
PearsK32G2303/01/2022

 

 

ProductSupplierDate Delivered
ApplesH1202/02/2022
ApplesG2304/01/2022
OrangesH1203/02/2022
OrangesF3402/02/2022
PearsK3202/02/2022
PearsG2302/02/2022

 

 

many thanks

J

  • Hi, Anonymous 

    You can consider using lookupvalue to create a calculated column in the bill table to integrate the data in the other two tables

    Date Due =
    SWITCH (
        'Bills Table'[Type],
        "Heavy",
            LOOKUPVALUE (
                'Table Heavy Products'[Date Due],
                'Table Heavy Products'[Product], 'Bills Table'[Product]
            ),
        "Light",
            LOOKUPVALUE (
                'Table Light Products'[Date Due],
                'Table Light Products'[Product], 'Bills Table'[Product]
            )
    )
    

    Best Regards,
    Community Support Team _ Eason

5 Replies

  • Anonymous , Create common dimension product and supplier and date. join with both tbales

     

    example

    Product = distinct(union(distinct(Table1[Product]),distinct(Table2[Product]) ))

     

    refer

    Bridge Table: https://www.youtube.com/watch?v=Bkf35Roman8&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=19

     

     

    for date

    To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thanks @amitchandak 

     

    I'll give this a try. 

     

    Will the new Product table auto update if new products are added to Table1 after i've made the Product table?

    • v-easonf-msft's avatar
      v-easonf-msft
      Community Support

      Hi,  Anonymous 

      You can create a Supplier_Product field and create the relationship based on this new field.

       

      But you need to unpivot column"Supplier1" and column “Supplier2” in Table1 first.

      Product Date Due Supplier
      Apples 1/1/2022 H12
      Apples 1/1/2022 G23
      Oranges 2/1/2022 H12
      Oranges 2/1/2022 F34
      Pears 3/1/2022 K32
      Pears 3/1/2022 G23

       

       

      Please check my attached file for more details.

       

      Best Regards,
      Community Support Team _ Eason

  • Anonymous's avatar
    Anonymous
    Not applicable

    Ok Thanks so much, i think i'm making some progress.

     

    I'm not sure if this is a completely new question or related to the above. 

     

    If i have the 3 tables below and i want to track the 4 products to see if they've arrived, or see which suppliers perform well etc, what is the best way to go about this?

     

    Table Heavy Products  
    ProductSupplierTypeDate Due
    ApplesH12Heavy01/02/2021
    OrangesG14Heavy03/01/2021

     

     

    Table Light Products  
    ProductSupplierTypeDate Due
    ApplesH12Light01/02/2021
    OrangesH12Light02/01/2021

     

     

    Bills Table    
    ProductSupplierTypeDate ArrivedCost
    ApplesH12Heavy01/02/2021 £             20.00
    ApplesH12Light02/01/2021 £             30.00
    OrangesH12Heavy03/01/2021 £             20.00
    OrangesG14Light  
    • v-easonf-msft's avatar
      v-easonf-msft
      Community Support

      Hi, Anonymous 

      You can consider using lookupvalue to create a calculated column in the bill table to integrate the data in the other two tables

      Date Due =
      SWITCH (
          'Bills Table'[Type],
          "Heavy",
              LOOKUPVALUE (
                  'Table Heavy Products'[Date Due],
                  'Table Heavy Products'[Product], 'Bills Table'[Product]
              ),
          "Light",
              LOOKUPVALUE (
                  'Table Light Products'[Date Due],
                  'Table Light Products'[Product], 'Bills Table'[Product]
              )
      )
      

      Best Regards,
      Community Support Team _ Eason