Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi!
I want to create a measure that calculates the average of the past 3 months sales based on selected months.
For example :
Months | Sales |
Jan | 1203 |
Feb | 2389 |
Mar | 3957 |
Apr | 4850 |
May | 1637 |
Jun | 9473 |
Jul | 4749 |
Aug | 4846 |
Sep | 4759 |
Oct | 2484 |
Nov | 4748 |
Dec | 7829 |
If the selected month is 'July', then the measure output will be:
(sales jun + sales may + sales april) / 3 = (9473 + 1637 + 4850) / 3 = 5320.
Please help, thank you!
Solved! Go to Solution.
Hi @spacegurl ,
We can use dates in period wrapped in a calculate function to create the desired output.
Avg3months =
CALCULATE (
AVERAGE ( Sheet1[Sales] ),
DATESINPERIOD ( Sheet1[Months], LASTDATE ( Sheet1[Months] ), -3, MONTH )
)
Desired Output:
Hope that helps 🙂
Hi @spacegurl ,
Whether the advice given by @Anonymous has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.
Looking forward to your feedback.
Best Regards,
Henry
Hi @spacegurl ,
We can use dates in period wrapped in a calculate function to create the desired output.
Avg3months =
CALCULATE (
AVERAGE ( Sheet1[Sales] ),
DATESINPERIOD ( Sheet1[Months], LASTDATE ( Sheet1[Months] ), -3, MONTH )
)
Desired Output:
Hope that helps 🙂