The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now
Hi all,
I'm hoping someone can help, I've been trying to Create a measure to work out an average of a column which has 1 & 0 over a 28 day period so when this is grouped by month or week in a matrix it would average the column
Average over 28 day period = VAR LAST_DATE = FIRSTDATE( 'Query1'[ORDERDATE].[Date]) RETURN AVERAGEX( DATESBETWEEN( 'Query1'[ORDERDATE].[Date], LAST_DATE, DATEADD(LAST_DATE,28,DAY) ), CALCULATE(AVERAGE('Query1'[Call Driver])) )
This was my last attempt to create a measure.
as a calculated column, I would have used this
Average over 28 days = VAR 28daysafter = [ORDERDATE] + 28 VAR IDtoCheck = [AGENTID] RETURN CALCULATE ( AVERAGE(Query1[Call Driver]), ALL(Query1), 'Query1'[AGENTID] = IDtoCheck, Query1[ORDERDATE]+1 <= 28daysafter )
Any help would be appreciated
Thanks
Liam
Solved! Go to Solution.
Hi LRiley,
According to your description, it seems that you want to calculate rolling average based on month and id, right? If so, you could try to use below measure to see whether it work or not
rolling sum = CALCULATE ( SUM ( avg28[amount] ), FILTER ( ALL ( avg28 ), avg28[date] <= MIN ( avg28[date] ) + 28 && avg28[date] >= MIN ( avg28[date] ) && avg28[id] = MIN ( avg28[id] ) && avg28[month] = MIN ( avg28[month] ) ) ) rolling avg = [rolling sum]/28
If this is not what you want, please correct me and inform me more detailed information(such as your sample data and expecting output), then I will help you more correctly.
Best Regards,
Zoe Zhi
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi LRiley,
According to your description, it seems that you want to calculate rolling average based on month and id, right? If so, you could try to use below measure to see whether it work or not
rolling sum = CALCULATE ( SUM ( avg28[amount] ), FILTER ( ALL ( avg28 ), avg28[date] <= MIN ( avg28[date] ) + 28 && avg28[date] >= MIN ( avg28[date] ) && avg28[id] = MIN ( avg28[id] ) && avg28[month] = MIN ( avg28[month] ) ) ) rolling avg = [rolling sum]/28
If this is not what you want, please correct me and inform me more detailed information(such as your sample data and expecting output), then I will help you more correctly.
Best Regards,
Zoe Zhi
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
160 | |
111 | |
96 | |
86 | |
75 |
User | Count |
---|---|
158 | |
136 | |
133 | |
81 | |
61 |