Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi,
I would like to create a measure that is the rolling average of the values from another measure (a percent). I would like the measure to add up those percentages that are between the current record date and those that are within the last six days and average the result. I'm fairly new to Dax, but have spent several hours trying to figure out the synatax when dealing with an average of a measure and not a column. However, every way I try this I run into problems with the % Coverage column being a measure and not a column. I wonder if anyone can point me in the right direction? I have tried something like this and it didn't give me the correct results.
Solved! Go to Solution.
[Average Sales 1] =
var PeriodToAverageOver =
DATESINPERIOD(
// I just hope this table is a
// properly built date table.
// IF not, please read dax.guide/datesinperiod
// and build a table they talk about
// in there.
'qry_Calendar'[Date],
MAX( 'qry_Calendar'[Date] ),
-6,
DAY
)
var Result =
AVERAGEX(
PeriodToAverageOver,
// I hope the below is a
// measure. It can't be
// a column in a table.
[Coverage Sales%]
)
return
Result
// Now, go to https://www.sqlbi.com/articles/rules-for-dax-code-formatting/
// and follow the rules RELIGIOUSLY. You'll
// thank me later 🙂
[Average Sales 1] =
var PeriodToAverageOver =
DATESINPERIOD(
// I just hope this table is a
// properly built date table.
// IF not, please read dax.guide/datesinperiod
// and build a table they talk about
// in there.
'qry_Calendar'[Date],
MAX( 'qry_Calendar'[Date] ),
-6,
DAY
)
var Result =
AVERAGEX(
PeriodToAverageOver,
// I hope the below is a
// measure. It can't be
// a column in a table.
[Coverage Sales%]
)
return
Result
// Now, go to https://www.sqlbi.com/articles/rules-for-dax-code-formatting/
// and follow the rules RELIGIOUSLY. You'll
// thank me later 🙂
I just wanted to thank you for that solution. I really have been struggling all day on it and I appreciate that you would take the time to answer....and yes, I'm will investigate the proper format for following dax code formatting "religiously" going forward.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
10 |
User | Count |
---|---|
19 | |
16 | |
14 | |
11 | |
9 |