Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Please see below data. I am calculating total sales divided by total hours in column I by employee. But I would like to calculate last 2 weeks average by employee in column J.
So for example in Column J, I am calculating last 2 weeks average per employee. How would I do that in Power BI? How would I create column J? So for example for Mike it is calculating (10+10)/(25+25) and for Sonia it is calculating (10+15)/(25+25)
Hi @homboy27 ,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you!!
@homboy27 change the DAX measure to this, and replace the value of __lastHowManyWeeks with 8 or whatever value you want, you can also make it dynamic:
Last x Weeks Average =
VAR __LastHowManyWeeks = 2 --change this to number of weeks you are looking for.
VAR __WeekEnding = MAX ( 'Table'[Week Ending] )
VAR __WeekStart = __WeekEnding - ( ( __LastHowManyWeeks - 1 ) * 7 )
RETURN
AVERAGEX (
FILTER (
ALLSELECTED ( 'Table'[Week Ending] ),
'Table'[Week Ending] >= __WeekStart && 'Table'[Week Ending] <= __WeekEnding
),
[% Hours]
)
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thank you, what do you mean by make it more dynamic?
thank you, what is the formuala if I wanted to do average of last 8 weeks?
Hi @homboy27 ,
Thank you for reaching out to Microsoft Fabric Community.
please find the below measure to calculate for 8 weeks. Also attached the pbix file for reference.
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Hi @homboy27 ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If the responses has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you!!
Hi @homboy27 ,
I hope the information provided is helpful. Feel free to reach out if you have any further questions or would like to discuss this in more detail. If responses provided answers your question, please accept it as a solution so other community members with similar problems can
find a solution faster.
Thank you!!
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 58 | |
| 45 | |
| 42 | |
| 20 | |
| 18 |
| User | Count |
|---|---|
| 172 | |
| 110 | |
| 91 | |
| 55 | |
| 45 |