Forum Discussion
Dynamic currency conversion help
- 3 years ago
try
Invoiced net sales converted = VAR SelectedCurrency = SELECTEDVALUE ( 'Exch rate'[Currency] ) RETURN IF ( NOT ISBLANK ( SelectedCurrency ), SUMX ( 'Table', VAR ReferenceDate = 'Table'[Invoice date] VAR ReferenceAmount = 'Table'[Invoiced net sales] VAR ExchRate = CALCULATE ( MAX ( 'Exch rate'[_EXCH_RATE] ), 'Exch rate'[Currency] = SelectedCurrency, 'Exch rate'[Date] = DATE( YEAR( ReferenceDate), MONTH(ReferenceDate),1) ) RETURN ExchRate * ReferenceAmount ) )
Hi johnt75 ,
Thanks for the solution.
I tested your solution and it looks like its only reading data on 1st of each month.
In exchange table , I have ave rate by month.
Ex: date Exch AVE rate
6/1/2020 0.12
7/1/2020 0.09
8/1/2020 1.19
Example : 6/1/2020 Converting correctly.
6/2/2020 I see blank althought there is data.
Could you please help.
Thank you SO MUCH
try
Invoiced net sales converted =
VAR SelectedCurrency =
SELECTEDVALUE ( 'Exch rate'[Currency] )
RETURN
IF (
NOT ISBLANK ( SelectedCurrency ),
SUMX (
'Table',
VAR ReferenceDate = 'Table'[Invoice date]
VAR ReferenceAmount = 'Table'[Invoiced net sales]
VAR ExchRate =
CALCULATE (
MAX ( 'Exch rate'[_EXCH_RATE] ),
'Exch rate'[Currency] = SelectedCurrency,
'Exch rate'[Date] = DATE( YEAR( ReferenceDate), MONTH(ReferenceDate),1)
)
RETURN
ExchRate * ReferenceAmount
)
)- Puja3 years agoHelper III
johnt75 ,
This is working GREAT. Thank you SO MUCH.
I want to ask for some more help. How can I use this same measure with the USERELATIONSHIP function? I have two other dates looking at different amounts in the same fact table. I did try, but it's not working for me.THANKS AGAIN 🙂
- johnt753 years agoSuper User
You'd need to change the columns in the ReferenceDate and ReferenceAmount columns. If you need to be able to chart it against the different dates you might wrap the whole thing inside CALCULATE( ..., USERELATIONSHIP('Table2'[Date],'Date'[Date]))