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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
delsbg
Helper I
Helper I

Pulling rate from exchage rate table

My rate table is constructed as such:

 

Currency   Date             Rate

USD          1/1/2020      1.33

USD          1/15/2020    1.31

USD          1/21/2020    1.28

 

I have a sales table with a sales date from almost every day.  I need to pull the exchange rate into the sales table for every day of the year even though the exchange rate table above only contains the date the rate changed.  How do I pull the exchange rate for say 1/10/2020 which of course I need 1.33?

 

 

1 ACCEPTED SOLUTION

Hi, @delsbg 

Unfortunately, merge query is not supported in direct query mode, I got the same error as yours when I tested it. My opinion is that we should use as less calculated column/table as we can in direct query mode, which can affect the performance of the report. As a result, you can consider making the merge query in the data source (like Sqlserver database), or you can just switch into import mode for more data transformation functions and faster query speed

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-robertq-msft
Community Support
Community Support

Hi, @delsbg 

According to your description, you want to pull the exchange rate into the sales table for every day of the year, I suggest you achieve it through Power query editor, you can follow my steps:

  1. Go to Power query editor, click on the ‘Sales’ table, select merge query:

v-robertq-msft_0-1605073540198.png

 

  1. Set the merge query like this:

v-robertq-msft_1-1605073540203.png

 

  1. Expand the table:

屏幕截图 2020-11-11 134848.png

  1. Get this column with null values, then click “fill down”

屏幕截图 2020-11-11 134858.png

And you can get what you want, like this:

屏幕截图 2020-11-11 134914.png

You can download my test pbix file here

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This is a good approach thank you.  Unfortunately I should have included in my original post that I need to stay in DirectQuery.  Fill down seems to kick me out of DirectQuery when I merge the two based on dates.  I will continue to fiddle with that approach though.  

Hi, @delsbg 

Unfortunately, merge query is not supported in direct query mode, I got the same error as yours when I tested it. My opinion is that we should use as less calculated column/table as we can in direct query mode, which can affect the performance of the report. As a result, you can consider making the merge query in the data source (like Sqlserver database), or you can just switch into import mode for more data transformation functions and faster query speed

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

DataInsights
Super User
Super User

@delsbg,

 

Try this calculated column in the Sales table:

 

Exchange Rate = 
VAR vCurrentDate = Sales[Date]
VAR vMaxDate =
    CALCULATE ( MAX ( ExchangeRate[Date] ), ExchangeRate[Date] <= vCurrentDate )
VAR vResult =
    CALCULATE ( MAX ( ExchangeRate[Rate] ), ExchangeRate[Date] = vMaxDate )
RETURN
    vResult

 

DataInsights_0-1605038627851.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




fx..jpg

 

This is what it looks like when I use that formula. I'm using DirectQuery if that matters..

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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