Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello,
I'm a beginner when it comes to DAX within Power BI, and I've been trying to solve the following problem:
I need to calculate the average interest rate for the previous 5 business days at the start of each week. My table, which is derived from public data, can be viewed below.
The formula I've come up with is close but fails to filter out business days. I'm really not sure how to do that; I thought that's what the Filter within the Calculate function was for.
Any help or guidance is apprecaited. I'm trying to create a calculated column.
Solved! Go to Solution.
For anyone curious, I ended up with the following code. It requires a Date table.
I don't think this is the most efficient way to do this, but it works for now.
For anyone curious, I ended up with the following code. It requires a Date table.
I don't think this is the most efficient way to do this, but it works for now.
Hi, @Anonymous
Based on my research, you may try to use the following calculated column.
Test2DDM5 =
IF (
WeekDay = 1,
CALCULATE (
AVERAGE ( 'FRED - Series - DFF'[Attribute:value] ),
FILTER (
DATESBETWEEN (
ALL('FRED - Series - DFF'[Attribute:date],
EARLIER ( 'FRED - Series - DFF'[Attribute:date] ) - 8,
EARLIER ( 'FRED - Series - DFF'[Attribute:date] ) - 1
),
'FRED - Series - DFF'[BusinessDayIndicator] = 1
)
)
)
If it doesn't work. Please show me your sample pbix file. Do mask sensitive data before uploading. Thanks.
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello @v-alq-msft ,
Thank you for your reply.
I tried plugging in your calculated column, but it only resulted in an error. I think you're missing a parenthesis after the ALL function, but even with trying to rectify that, there is an error.
For your convenience, I recreated the file with only the data you need based on the calculation you provided. This file contains public data from the Federal Reserve. However, I don't see a way for me to upload the file for you...