Forum Discussion
Lookup value with multiple filters
- 5 years ago
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
)
)
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
- Jihwan_Kim5 years ago
Super User
You are right.
If you do not have other currencies, it is not mandatorily needed.- JimJim5 years ago
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
- Jihwan_Kim5 years ago
Super User
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
)
)