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

The Fabric Community site will be in read-only mode on Monday, Feb 24 from 12:01 AM to 8 AM PST for scheduled upgrades.

Reply
Cyriackpazhe
Helper II
Helper II

lookupvalue

Can someone help me out with the usage of two lookupvalue and how the expanded table avoids itScreenshot (6).pngScreenshot (7).png

2 REPLIES 2
v-denglli-msft
Community Support
Community Support

Hi @Cyriackpazhe ,

 

May I ask if you have gotten this issue resolved?
If it is solved, please mark the helpful reply or share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster .
Thank you very much for your kind cooperation!

 

Best Regards,
Dengliang Li

DataNinja777
Super User
Super User

Hi @Cyriackpazhe ,

 

The first approach in the image uses two separate LOOKUPVALUE calls to retrieve the exchange rate. The first LOOKUPVALUE retrieves the CurrencyKey for "EUR" from the Currency table, which is then used in a second LOOKUPVALUE to fetch the exchange rate from the Daily Exchange Rates table based on the retrieved CurrencyKey and the Order Date from the Sales table. This method works but is less efficient because it requires multiple queries.

ExchangeRateToEUR =
VAR CurrencyKey =
    LOOKUPVALUE (
        'Currency'[CurrencyKey],
        'Currency'[Currency Code], "EUR"
    )
VAR CurrentDate = Sales[Order Date]
VAR Result =
    LOOKUPVALUE (
        'Daily Exchange Rates'[Rate],
        'Daily Exchange Rates'[CurrencyKey], CurrencyKey,
        'Daily Exchange Rates'[Date], CurrentDate
    )
RETURN
    Result

The optimized approach eliminates the need for the first LOOKUPVALUE call by leveraging the expanded table, which allows direct searching into the Currency table without first retrieving CurrencyKey. Since the expanded table includes related data, the Currency Code column from Currency can be used directly inside LOOKUPVALUE, making the query more efficient by reducing redundancy.

ExchangeRateToEUR =
VAR CurrentDate = Sales[Order Date]
VAR Result =
    LOOKUPVALUE (
        'Daily Exchange Rates'[Rate],
        'Currency'[Currency Code], "EUR",
        'Daily Exchange Rates'[Date], CurrentDate
    )
RETURN
    Result

By using the expanded table, this version avoids unnecessary lookups, allowing LOOKUPVALUE to work with the Currency Code column directly instead of first retrieving CurrencyKey. This approach simplifies the calculation and improves performance, especially when working with large datasets.

 

Best regards,

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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