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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.