Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi,
Would appreciate help with mapping a DAX formula.
I have a lookupvalue that checks the currency for each day, here is the formula:
ExchangeRateUSD = IF(ISBLANK(LOOKUPVALUE(
'All currencyExchangeRates'[relationalExchangeRateAmount],
'All currencyExchangeRates'[StartingDateFormatted], Opportunities[ExchangeRateDate],
'All currencyExchangeRates'[currencyCode], Opportunities[CurrencyFormat_USD])),
LOOKUPVALUE(
'All currencyExchangeRates'[relationalExchangeRateAmount],
'All currencyExchangeRates'[StartingDateFormatted], DATE(Opportunities[ExchangeRateDate].[Year], Opportunities[ExchangeRateDate].[MonthNo], Opportunities[ExchangeRateDate].[Day]) - 3,
'All currencyExchangeRates'[currencyCode], Opportunities[CurrencyFormat_USD]),
LOOKUPVALUE(
'All currencyExchangeRates'[relationalExchangeRateAmount],
'All currencyExchangeRates'[StartingDateFormatted], Opportunities[ExchangeRateDate],
'All currencyExchangeRates'[currencyCode], Opportunities[CurrencyFormat_USD]))
Here is a summary of what it does:
Is there any way to fix to make a lookup so that it looks a value within 3 days prior, and if there is data perhaps one day prior instead, it chooses that day instead of 3? An example would be:
If we have data missing for example on the 15th of January, and data on the 14th January and 12th of January, I would like it to grab data from the 14th instead?
Thanks
Solved! Go to Solution.
Hi @Anonymous ,
You can use the function with a function that searches for the closest date within a range of dates.
Below is the DAX might work for you:
ExchangeRateUSD = IF(ISBLANK(LOOKUPVALUE(
'All currencyExchangeRates'[relationalExchangeRateAmount],
'All currencyExchangeRates'[StartingDateFormatted], Opportunities[ExchangeRateDate],
'All currencyExchangeRates'[currencyCode], Opportunities[CurrencyFormat_USD])),
LOOKUPVALUE(
'All currencyExchangeRates'[relationalExchangeRateAmount],
'All currencyExchangeRates'[StartingDateFormatted],
MAXX(
FILTER(
'All currencyExchangeRates',
'All currencyExchangeRates'[currencyCode] = Opportunities[CurrencyFormat_USD] &&
'All currencyExchangeRates'[StartingDateFormatted] >= DATE(Opportunities[ExchangeRateDate].[Year], Opportunities[ExchangeRateDate].[MonthNo], Opportunities[ExchangeRateDate].[Day]) - 3 &&
'All currencyExchangeRates'[StartingDateFormatted] <= Opportunities[ExchangeRateDate]
),
'All currencyExchangeRates'[StartingDateFormatted]
),
'All currencyExchangeRates'[currencyCode], Opportunities[CurrencyFormat_USD]),
LOOKUPVALUE(
'All currencyExchangeRates'[relationalExchangeRateAmount],
'All currencyExchangeRates'[StartingDateFormatted], Opportunities[ExchangeRateDate],
'All currencyExchangeRates'[currencyCode], Opportunities[CurrencyFormat_USD]))
This modified formula uses the function to find the closest date within a range of dates. The function searches for all dates within 3 days prior to the exchange rate date and the exchange rate date itself.
Best Regards,
Xianda Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
You can use the function with a function that searches for the closest date within a range of dates.
Below is the DAX might work for you:
ExchangeRateUSD = IF(ISBLANK(LOOKUPVALUE(
'All currencyExchangeRates'[relationalExchangeRateAmount],
'All currencyExchangeRates'[StartingDateFormatted], Opportunities[ExchangeRateDate],
'All currencyExchangeRates'[currencyCode], Opportunities[CurrencyFormat_USD])),
LOOKUPVALUE(
'All currencyExchangeRates'[relationalExchangeRateAmount],
'All currencyExchangeRates'[StartingDateFormatted],
MAXX(
FILTER(
'All currencyExchangeRates',
'All currencyExchangeRates'[currencyCode] = Opportunities[CurrencyFormat_USD] &&
'All currencyExchangeRates'[StartingDateFormatted] >= DATE(Opportunities[ExchangeRateDate].[Year], Opportunities[ExchangeRateDate].[MonthNo], Opportunities[ExchangeRateDate].[Day]) - 3 &&
'All currencyExchangeRates'[StartingDateFormatted] <= Opportunities[ExchangeRateDate]
),
'All currencyExchangeRates'[StartingDateFormatted]
),
'All currencyExchangeRates'[currencyCode], Opportunities[CurrencyFormat_USD]),
LOOKUPVALUE(
'All currencyExchangeRates'[relationalExchangeRateAmount],
'All currencyExchangeRates'[StartingDateFormatted], Opportunities[ExchangeRateDate],
'All currencyExchangeRates'[currencyCode], Opportunities[CurrencyFormat_USD]))
This modified formula uses the function to find the closest date within a range of dates. The function searches for all dates within 3 days prior to the exchange rate date and the exchange rate date itself.
Best Regards,
Xianda Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!