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
JimJim
Responsive Resident
Responsive Resident

Lookup value with multiple filters

Hi Team,
I have two tables, Sales and Currency. See below:

Annotation 2021-06-23 133645.jpg
I would like to populate Sales.Exchange Rate GBP and Sales.Exchange Rate USD with the exchange rates from the currency table (values above are my expected results)
The logic I need to use looks something like this (For GBP):

select earliest exchange rate from Currency where Sales.Currency = Currency.Source and Currency.Target = 'GBP' and Sales.Date > Currency.Date


How can I accomplish this?

1 ACCEPTED SOLUTION

 

https://www.dropbox.com/s/o04lz90nbzttotv/reporting%20model.pbix?dl=0 

 

Exchange rate GBP CC=
VAR sourcecurrency = Requests[Currency]
VAR targetcurrency = "GBP"
VAR currentdate = Requests[Date Requested]
VAR maxcurrencydate =
CALCULATE (
MAX ( 'Currency'[date] ),
FILTER (
'Currency',
'Currency'[date] <= currentdate
&& 'Currency'[sourcecurrency] = sourcecurrency
&& 'Currency'[targetcurrency] = targetcurrency
)
)
RETURN
CALCULATE (
CALCULATE ( SUM ( 'Currency'[exchangerate] ) ),
FILTER (
'Currency',
'Currency'[date] = maxcurrencydate
&& 'Currency'[sourcecurrency] = sourcecurrency
&& 'Currency'[targetcurrency] = targetcurrency
)
)

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

7 REPLIES 7
JimJim
Responsive Resident
Responsive Resident

Thank you @Jihwan_Kim ,

I appreciate the time you spent doing this, I will try and make it work

Jihwan_Kim
Super User
Super User

 

Picture1.png

 

Qty total : =
SUM(Sales[Qty])
 
Currency : =
IF( ISFILTERED(Dates[Date]),
SELECTEDVALUE(Sales[Currency]))
 
Exchange rate GBP =
VAR _sourcecurrency =
MAX ( SourceCurrency[Source] )
VAR _currentdate =
MAX ( Dates[Date] )
RETURN
IF (
NOT ISBLANK ( [Qty total :] )&& ISFILTERED(Dates[Date]),
CALCULATE (
LASTNONBLANKVALUE (
Dates[Date],
CALCULATE (
SUM ( 'Currency'[Rate] ),
FILTER (
'Currency',
'Currency'[Source] = _sourcecurrency
&& 'Currency'[Target] = "GBP"
)
)
),
FILTER ( ALL ( Dates ), Dates[Date] <= _currentdate )
)
)
 
Exchange rate USD =
VAR _sourcecurrency =
MAX ( SourceCurrency[Source] )
VAR _currentdate =
MAX ( Dates[Date] )
RETURN
IF (
NOT ISBLANK ( [Qty total :] ) && ISFILTERED(Dates[Date]),
CALCULATE (
LASTNONBLANKVALUE (
Dates[Date],
CALCULATE (
SUM ( 'Currency'[Rate] ),
FILTER (
'Currency',
'Currency'[Source] = _sourcecurrency
&& 'Currency'[Target] = "USD"
)
)
),
FILTER ( ALL ( Dates ), Dates[Date] <= _currentdate )
)
)
 
 
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
JimJim
Responsive Resident
Responsive Resident

I see you have created a SourceCurrency table, is this a necessary step in addition to my current currency table? My source currencies have more than just AUD so ideally I would rather not have to create this

J

You are right.
If you do not have other currencies, it is not mandatorily needed.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
JimJim
Responsive Resident
Responsive Resident

Hi @Jihwan_Kim 

I have tried to implement your solution but it is not working, I have attached a link to a PowerBI model. As you can see I am trying to add a new column to my table 'Requests' but it is returning no results

https://1drv.ms/u/s!Avci50weR29DvlH-xbTb5oK5NI7U?e=qyjClq 

 

https://www.dropbox.com/s/o04lz90nbzttotv/reporting%20model.pbix?dl=0 

 

Exchange rate GBP CC=
VAR sourcecurrency = Requests[Currency]
VAR targetcurrency = "GBP"
VAR currentdate = Requests[Date Requested]
VAR maxcurrencydate =
CALCULATE (
MAX ( 'Currency'[date] ),
FILTER (
'Currency',
'Currency'[date] <= currentdate
&& 'Currency'[sourcecurrency] = sourcecurrency
&& 'Currency'[targetcurrency] = targetcurrency
)
)
RETURN
CALCULATE (
CALCULATE ( SUM ( 'Currency'[exchangerate] ) ),
FILTER (
'Currency',
'Currency'[date] = maxcurrencydate
&& 'Currency'[sourcecurrency] = sourcecurrency
&& 'Currency'[targetcurrency] = targetcurrency
)
)

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
JimJim
Responsive Resident
Responsive Resident

Hi @Jihwan_Kim ,

Thank you, it works.

I had to add a DATEVALUE function to my currentdate variable as it was complaining about comparing date and strings.

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.