Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register 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.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 54 | |
| 37 | |
| 34 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 72 | |
| 72 | |
| 38 | |
| 35 | |
| 26 |