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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jacinto
Frequent Visitor

Filter many-to-many relationship based on row value in the current table

I am struggling to create measure to calculate value for each code in Sales table using Exchange table columns. The two tables are many-to-many related, I can't add column or create table because those tables come from diffent composite models. 

 

What I would like is just to calculate sales value to common currency (EUR) therefore, I have to grap corresponding multiplier for a given currency IF Sales[date] >= Exchange[rate date] AND date <= Exchange[rate date next]

I tried the following but I get error. Thanks in advance

 

ToEUR =

VAR vCurr =

SELECTEDVALUE( 'Sales'[currency])

VAR vRefDat =SELECTEDVALUE ('Sales'[date])

VAR vExRate =

CALCULATE (

AVERAGE ( 'Exchange'[multiplier]),

FILTER (

'Exchange ',

'Exchange '[currency] = vCurr

&& 'Exchange '[rate date] <= vRefDat

&& 'Exchange '[rate date next] >= vRefDat

)

)

VAR Result = IF(vCurr="EUR", 1, vExchangeRate)

RETURN Result

 

Sales table

code

date

volume 

price

currency

3322

22/2/2016

5

1

EUR

3436

22/1/2017

8

2

USD

1322

22/02/2018

10

3

AUD

9436

12/11/2019

3

2

EUR

 

Exchange 

currency

multiplier

rate date

rate date next

AUD

2,0

22/02/2018

23/02/2018

USD

1,1

22/1/2017

23/1/2017

EUR

1,0

22/2/2016

22/2/2016

 

 

 

 

 

 

3 REPLIES 3
SIH007_1
Frequent Visitor

How do you expect SELECTEDVALUE( 'Sales'[currency]) to work in a many to many relationship? If you want to use SELECTEDVALUE you have to make sure that the outcome is unique.

v-zhangti
Community Support
Community Support

Hi, @jacinto 

 

Where is it wrong? What should your desired outcome look like?

vzhangti_0-1658223160326.png

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more.

lbendlin
Super User
Super User

Add a composite key "CurrencyMonth" to both tables and link via that key. It will be 1:M from the FX table to the sales table.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors
Top Kudoed Authors