Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
erhan_79
Post Prodigy
Post Prodigy

Creating New Teble

Hi There ;

 

i need to create a new table from two other table.I have below two table Table A and Table B :

 

Capture1.JPG

 

i need a to create a new "table C " which includes sum of the quantities based on material codes as below 

 

Capture2.JPG

Could you pls help me to create a new table , thanks in advance 

 

 

 

 

2 ACCEPTED SOLUTIONS
jaideepnema
Solution Sage
Solution Sage

Hi @erhan_79 ,

Did you tried appending the two tables into one ?

View solution in original post

PaulDBrown
Community Champion
Community Champion

@erhan_79 

I take it you want a new table within the model?

You can do this easily in Power Query by appending both tables and  grouping by the material code.

If you want to do it using DAX, try:

1) Create simple sum measures for each quantity

2) Create a total quantity for each material code in each table using:

T1 total =
[SUM T1]
    + CALCULATE (
        [SUm T2],
        TREATAS ( VALUES ( 'Table 1'[Material Code] ), 'Table 2'[Material Code] )
    )
T2 total =
[SUM T2]
    + CALCULATE (
        [SUm T1],
        TREATAS ( VALUES ( 'Table 2'[Material Code] ), 'Table 1'[Material Code] )
    )

3) and finally the DAX to create the new table:

New Table =
VAR T1 =
    ADDCOLUMNS (
        'Table 1',
        "Material Codes", 'Table 1'[Material Code],
        "Quantities", [T1 total]
    )
VAR T2 =
    ADDCOLUMNS (
        'Table 2',
        "Material Codes", 'Table 2'[Material Code],
        "Quantities", [T2 total]
    )
RETURN
    SUMMARIZE ( UNION ( T1, T2 ), [Material Codes], [Quantities] )

 

New Table.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

6 REPLIES 6
TomMartens
Super User
Super User

Hey @erhan_79 ,

 

you can use this DAX statement to create the new table:

Table 2 = 
GROUPBY(
    UNION(
        'Table A'
        , 'Table B'
    )
    , [Material Code]
    , "Quantity" , SUMX( CURRENTGROUP() , [Quantity] )
)

Hopefully, this provides what you are looking for.

 

If not, create a pbix that contains sample data, but still reflects your data model. Upload the pbix to onedrive or dropbox and share the link. If you are using Excel to create sample data, share the xlsx as well.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

@TomMartens 

Much more elegant than my long winded attempt! I didn't know about the CURRENTGROUP function!

learn something new every day...





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






jaideepnema
Solution Sage
Solution Sage

@erhan_79 yes append the two tables into one and then create the required visualization using the new table. 

 

Please accept this as a solution if your question is answered !!

Appreciate A Kudos 😀

PaulDBrown
Community Champion
Community Champion

@erhan_79 

I take it you want a new table within the model?

You can do this easily in Power Query by appending both tables and  grouping by the material code.

If you want to do it using DAX, try:

1) Create simple sum measures for each quantity

2) Create a total quantity for each material code in each table using:

T1 total =
[SUM T1]
    + CALCULATE (
        [SUm T2],
        TREATAS ( VALUES ( 'Table 1'[Material Code] ), 'Table 2'[Material Code] )
    )
T2 total =
[SUM T2]
    + CALCULATE (
        [SUm T1],
        TREATAS ( VALUES ( 'Table 2'[Material Code] ), 'Table 1'[Material Code] )
    )

3) and finally the DAX to create the new table:

New Table =
VAR T1 =
    ADDCOLUMNS (
        'Table 1',
        "Material Codes", 'Table 1'[Material Code],
        "Quantities", [T1 total]
    )
VAR T2 =
    ADDCOLUMNS (
        'Table 2',
        "Material Codes", 'Table 2'[Material Code],
        "Quantities", [T2 total]
    )
RETURN
    SUMMARIZE ( UNION ( T1, T2 ), [Material Codes], [Quantities] )

 

New Table.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






jaideepnema
Solution Sage
Solution Sage

Hi @erhan_79 ,

Did you tried appending the two tables into one ?

thats a good idea @jaideepnema 🙂 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.