Search code examples
powerbidaxcreate-table

PowerBI Creating New Table using values in other tables


I have multiple data tables in a Power BI report and am hoping to create a new summarized table with new column and selected columns and rows from other data tables. Each data tables are quite large with different data elements so it's difficult to append the tables together to form one big table. Below is a simplified version just to illustrate the issue and what i wanted to achieve:

ID 1 Name is Orange Table 1


ID 2 Name is Apple
Table 2
The last column: Sum Value (Agg.) in each table are Measures.

The result table I am trying to get is like below:
Result Table

So basically I wanted to use Table 1 and Table 2 to create a new summarized Table with an added column 'Item Name' replacing the 'ID' column and the 'Sum Value' column. So far I've tried the Summarize and AddColumn function but couldn't get Measure Sum Value to the table. If anyone can help, that'd be great!! Thankyou

Michelle


Solution

  • This reshaping should really be done in PQ but if you insist on DAX, here you go.

    Table = 
    
    VAR a =  ADDCOLUMNS(
        SUMMARIZE(Orange, Orange[Sum Value (Agg.)]),
        "Item Name",
        "Orange"
    )
    
    VAR b =  ADDCOLUMNS(
        SUMMARIZE(Apple, Apple[Sum Value (Agg.)]),
        "Item Name",
        "Apple"
    )
    
    RETURN UNION(a,b)
    

    enter image description here