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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.