Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hello! I'm stuck with a rather easy problem. Just can't figure out the right syntax for the formula. Problem: I need to get an average quote (exchange rate) calculated for the period starting on the 25th day two months prior and ending on 24th day one month prior and apply that measure to the measure in current month. The formula I came up with:
AD_EURO =
CALCULATE (
AVERAGEX ( 'CBR EURO', 'CBR EURO'[EURO-RUR] ),
FILTER (
Dates,
Dates[Date]
>= DATE ( YEAR ( DATEADD ( Dates[Date], -2, MONTH ) ), MONTH ( DATEADD ( Dates[Date], -2, MONTH ) ), 25 )
),
FILTER (
Dates,
Dates[Date]
<= DATE ( YEAR ( DATEADD ( Dates[Date], -2, MONTH ) ), MONTH ( DATEADD ( Dates[Date], -1, MONTH ) ), 24 )
)
)
But I'm getting no results. Using && instead of second filter returns no result as well. All connections are active.
Said time frame is set and adding or substracting days wont do the trick.
The result I'm trying to get
Thank you!
Solution from here won't help https://community.powerbi.com/t5/Desktop/Building-a-Date-from-Year-Month-and-Day-columns/td-p/953265
since it won't solve the year start/end periods
Solved! Go to Solution.
Found a workaround.
I've created additional columns FromDate and ToDate and used AVERAGEX with DATESBEWEEN
For the expression to work as measure just added min and max
AD_EURO =
CALCULATE (
AVERAGEx ( Dates,Dates[EURORUR_intermed]),
DATESBETWEEN(Dates[Date],MIN(Dates[FromDate]),MAX(Dates[ToDate])
))
Self service at its finest 😋
Added two columns to the dates table
FromDate =
DATE ( YEAR ( DATEADD ( Dates[Date], -2, MONTH ) ), MONTH ( DATEADD ( Dates[Date], -2, MONTH ) ), 25 )
ToDate =
DATE ( YEAR ( DATEADD ( Dates[Date], -1, MONTH ) ), MONTH ( DATEADD ( Dates[Date], -1, MONTH ) ), 24 )
To get a corresponding average for the date added another column
Average_USD =
CALCULATE (
AVERAGE ( Dates[USDRUR_intermed] ),
FILTER (
Dates,
Dates[Date] >= Dates[FromDate]
&& Dates[Date] <= Dates[ToDate]
)
)
Returns blank
When i use single condition - either >=FromDate or <=ToDate - average exchange rate is returned either for all the dates greater than first entry of FromDate or less than last entry of ToDate
STILL NEED HELP
Found a workaround.
I've created additional columns FromDate and ToDate and used AVERAGEX with DATESBEWEEN
For the expression to work as measure just added min and max
AD_EURO =
CALCULATE (
AVERAGEx ( Dates,Dates[EURORUR_intermed]),
DATESBETWEEN(Dates[Date],MIN(Dates[FromDate]),MAX(Dates[ToDate])
))
Self service at its finest 😋
Any ideas? Anyone...