Forum Discussion

zamurr's avatar
zamurr
Icon for Microsoft Employee rankMicrosoft Employee
10 years ago
Solved

Combine multiple tables into one table

  I have a massive data model that is getting big and slow. I was hoping for a way to combine a few of the tables into one big table. I know in Excel you can do it with a series of VLOOKUP, but I am...
  • Anonymous's avatar
    Anonymous
    10 years ago

    Hi zamurr,

     

    >> I am not sure if DAX can do this or not. I have read a bunch of articles but nothing seems to explain it quite like i want.

    Obviously, dax support this feature.

     

    You could use selectcolumns/addcolumns , related, lookupvalue functions to achieve your requirement.

    Below is my sample:

    Tables: ‘Person’, ’Product’, ’Type’, ’Records’, ’Gender’.

    ‘Person’

     

    ’Product’

     

    ’Type’

     

    ’Gender’

     

    ’Records’

     

    Relationship:

     

    Dax formula:

    Detail = SELECTCOLUMNS(Records,"Person Name",RELATED(Person[Name]),"Gender",LOOKUPVALUE(gender[Describe],gender[Index],RELATED(Person[gender])),"Type",RELATED('Type'[Type Name]),"Product Name",RELATED('Product'[Product Name]),"Price",RELATED('Product'[Price]),"Amount",Records[Amount],"Total",[Amount]*RELATED('Product'[Price]))

     

     

     

    Notice: if the columns have the relationship you could simple use Related() function to get the specify values. Otherwise, you could use LookupValue() to search the specify column.

     

    Regards,

    Xiaoxin Sheng