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.
Hi,
I have an exchange rate master in my model, with following columns:
I want to create a calculated column using Dax that gives Monthly Average Conversion Rate (aggregated on Currency From and Currency To). Also please note that Conversion rates might not be available for every date in a month, hence average needs to be calculated accordingly i.e. based on available rates only.
Please help!
Thanks in advance,
Shailee
Solved! Go to Solution.
I found the solution:
// There's always a better solution...
// You should know that you should avoid
// CALCULATE in calculated columns for
// performance reasons.
[Monthly Average Conversion Rate] =
var CurrentDate = 'Exchange Rate Master'[Conversion Date]
var CurrentFrom = 'Exchange Rate Master'[Currency From]
var CurrentTo = 'Exchange Rate Master'[Currency To]
Var MinDate = EOMONTH( CurrentDate, -1) + 1
Var MaxDate = EOMONTH( CurrentDate )
var Result =
AVERAGEX(
FILTER(
'Exchange Rate Master', true
&& 'Exchange Rate Master'[Currency From] = CurrentFrom
&& 'Exchange Rate Master'[Currency To] = CurrentTo
&& MinDate <= 'Exchange Rate Master'[Conversion Date]
&& 'Exchange Rate Master'[Conversion Date] <= MaxDate
),
'Exchange Rate Master'[Conversion Rate]
)
return
Result
// There's always a better solution...
// You should know that you should avoid
// CALCULATE in calculated columns for
// performance reasons.
[Monthly Average Conversion Rate] =
var CurrentDate = 'Exchange Rate Master'[Conversion Date]
var CurrentFrom = 'Exchange Rate Master'[Currency From]
var CurrentTo = 'Exchange Rate Master'[Currency To]
Var MinDate = EOMONTH( CurrentDate, -1) + 1
Var MaxDate = EOMONTH( CurrentDate )
var Result =
AVERAGEX(
FILTER(
'Exchange Rate Master', true
&& 'Exchange Rate Master'[Currency From] = CurrentFrom
&& 'Exchange Rate Master'[Currency To] = CurrentTo
&& MinDate <= 'Exchange Rate Master'[Conversion Date]
&& 'Exchange Rate Master'[Conversion Date] <= MaxDate
),
'Exchange Rate Master'[Conversion Rate]
)
return
Result
Thanks, will keep that in mind!
I found the solution:
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
42 | |
21 | |
21 | |
14 | |
13 |
User | Count |
---|---|
43 | |
39 | |
33 | |
18 | |
17 |