Forum Discussion

JimJim's avatar
JimJim
Icon for Responsive Resident rankResponsive Resident
5 years ago
Solved

Lookup value with multiple filters

Hi Team, I have two tables, Sales and Currency. See below: I would like to populate Sales.Exchange Rate GBP and Sales.Exchange Rate USD with the exchange rates from the currency table (values...
  • Jihwan_Kim's avatar
    Jihwan_Kim
    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
    )
    )