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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Truelearner
Helper III
Helper III

need help with dax

I have the table below where in i have original currency and transaction currency along with effective date and exchnage rate , 

 

i have this requirement where in which i want to create a table with with highest date when i have two or more exchange rates within same month and i want to have a column in which i would like to have the previous month exchnage rate if the current exchnage rate is not available.

 

@mgwena @cham @amitchandak @Greg_Deckler @Mariusz 

 

Input table :

 

Original currTransaction CurrEffective DateExchangerate
USDINR02-01-202071
USDINR18-01-202072.05
USDEUR07-01-202014
USDINR04-02-202071.5
USDCAD07-02-20201.01
USDINR03-03-202072

 

Output Table :

 

Original currTransaction CurrEffective DateExchangeratePrevious exchnage rate 
USDINR18-01-202072.05 
USDEUR07-01-20201472.0
USDCAD07-02-20201.01 
USDINR03-03-20207214
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Your result does seem in line with the description.

Please find solution at https://www.dropbox.com/s/ow37w9hj8aro25z/LastMonthExchnageRate.pbix?dl=0

 

Use Max month as filter

 

View solution in original post

3 REPLIES 3
v-gizhi-msft
Community Support
Community Support

Hi,

 

Create a MonthNo column first:

MonthNo = 'Table'[Effective Date].[MonthNo]

Add an index column in Query Editor.

Then try this measure:

check = IF(MAX('Table'[Effective Date])=MAXX(FILTER(ALL('Table'),'Table'[MonthNo] in FILTERS('Table'[MonthNo])),'Table'[Effective Date]),1,0)

Apply it to original table visual by setting check=1, it shows:

53.PNG

Then try this measure:

Previous exchnage rate = CALCULATE(MAX('Table'[Exchangerate]),FILTER(ALLSELECTED('Table'),'Table'[MonthNo]=MAX('Table'[MonthNo])-1))

The result shows:

54.PNG

Tips: Based on your logic, i think the expected output is like the above not the screenshot you posted.

        Please check it.

        If i have understood your requirement, please for free to let me know.

        Expect your reply!

Here is my test pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto Zhi

amitchandak
Super User
Super User

Your result does seem in line with the description.

Please find solution at https://www.dropbox.com/s/ow37w9hj8aro25z/LastMonthExchnageRate.pbix?dl=0

 

Use Max month as filter

 

Cristian_Angyal
Advocate III
Advocate III

Hello @Truelearner ,

 

Check-out this great article from SQLBI: https://www.sqlbi.com/articles/currency-conversion-in-power-bi-reports/

 

 

If you liked my solution please give it a thumbs up 👍

If I did answer your question please mark my post as a solution .

Thank you !

 

 

Cristian

 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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