Forum Discussion

mattramirez2020's avatar
6 years ago
Solved

Two key columns (one text and one number)

Hi, I am relatively new to Power BI. I have sales data with a product ID and a product type that I am trying to build a relationship to a product table. The product numbers repeat across the categories so they are not unique by themself. I know I could join the text name and the number ID but I have heard that relationships load faster if they use only numbers. Is there a better way beyond merging the columns to create this relationship? I have searched on youtube and here and I am afraid I am not searching using the correct terminology or missing an obvious solution! Any help would be appreciated.

 

Sales

Product TypeProduct ID
Left Product1
Right Product1
Left Product2
Right Product2

 

Products

Product TypeProduct IDDescriptionCost
Left Product1desc info5
Right Product1desc info 27
Left Product2desc info 43
Right Product2desc info 32
  • camargos88's avatar
    camargos88
    6 years ago

    mattramirez2020 .

     

    Check this code:

     

    However, if you have products on sales that is not on products table you have more works to do, like compare and add them to products table. Do you have this situation ?

4 Replies

  • mattramirez2020 , In M or Dax You can create a combined column in both tables and join on them

    new column

    Key = [Product Type] & " " & [Product ID]

    • mattramirez2020's avatar
      mattramirez2020
      Helper II

      camargos88 Thank you for helping out! What you did makes perfect sense but I just can't figure out how to do it. I was able to assign all the products a unique ID/key but I can't figure out how you map back sales to a new key/id that did not previously exist?

      • camargos88's avatar
        camargos88
        Community Champion

        mattramirez2020 .

         

        Check this code:

         

        However, if you have products on sales that is not on products table you have more works to do, like compare and add them to products table. Do you have this situation ?