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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How get distinct values from a table and use them to get data from related table?

I have a couple tables. FactTable1 is connected to all dimensions and FactTable2 has some preagregated data and has only one realtion to FactTable1 (many) <-FactTable2(one) using CompositeId.
Tables structure:

FactTable1
PrimaryId
CompositeId
....
Amount

and

FactTable2
CompositeId
DifferentAmount

I would like to use FactTable1 distinct CompositeId values and get a sum of FactTable2[DifferentAmount].
My current code that doesn't work:

 

//Code works, but return bigger result that expected
//probably, because the calculation has duplications and adds the same value 
//from FactTable2[DifferentAmount] several times
SUMX (
FactTable1,
RELATED (FactTable2[DifferentAmount])
)
//This code should remove duplicates, but it doesn't work 
SUMX (
DISTINCT (FactTable1[CompositeId]),
RELATED (FactTable2[DifferentAmount])
)

 

 

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , try like

SUMX (FactTable1,
maxx(values(FactTable1[CompositeId]),
RELATED (FactTable2[DifferentAmount]))
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.