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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
soldanr
Frequent Visitor

Sum Distinct Values from different tables in DAX

Hello,

 

I am trying to sum distinct values from 2 tables.

 

Table 1 containts the Part numbers shipped from location 1.

Table 2 containts the Part numbers shipped from location 2.

 

I would like to have a DAX table created that will sum the total quantity shipped of each part number.

 

SumValues.PNG

 

Any Help is appreciated,

Thanks

 

 

2 REPLIES 2
LivioLanzo
Solution Sage
Solution Sage

HI @soldanr

 

the simplest way to do this is to combine table1 and tabl2, adding an extra column to identify the location. 

afterwards, you can summarize this easily with a matrix

 

if you wanted to do it with a DAX query to create a new table, you can do it like this:

 

 

 

 

=
GROUPBY (
    UNION (
        ADDCOLUMNS ( Ship1, "Location""Location 1" ),
        ADDCOLUMNS (
            SELECTCOLUMNS ( Ship2, "PN", [PN], "QTYSHP1", [QTYSHP2] ),
            "Location""Location 2"
        )
    ),
    Ship1[PN],
    "TOT"SUMX ( CURRENTGROUP (), [QTYSHP1] )
)

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Unfortunately I am using direct query and I don't have the option to create a new table.

 

I like the union solution, it is very elegant but I can't make it work 😞

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.