Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Natasha93
Frequent Visitor

How to Show Average Last X Weeks in a Visual?

Hi 🙂

 

I have a clustered bar chart to show a count of cases created according to date by location.

I would like the visual to show the average cases from the last 4 weeks.

 

Snag_bf247e.png

 

I am wracking my brain around Time Intelligence DAX, but can't find anything definitive that works!

 

Any help will be much appreciated!

1 ACCEPTED SOLUTION
MisterFry
Resolver III
Resolver III

To solve these time intelligence issues, I maintain a calendar table that has a field that I call 'Week Offset Number'. The file contains an integer value describing the number of weeks into the past the indicated week is. (last week is -1, the week prior is -2). 
This makes the DAX to look at the 'last x weeks' or even the 'last x weeks from the selected week' DAX pretty easy. 

Average Measure = CALCULATE(AVERAGE(<FACT>), ALL(Calendar), Calendar[Week Offset Num] > -4)

View solution in original post

2 REPLIES 2
MisterFry
Resolver III
Resolver III

To solve these time intelligence issues, I maintain a calendar table that has a field that I call 'Week Offset Number'. The file contains an integer value describing the number of weeks into the past the indicated week is. (last week is -1, the week prior is -2). 
This makes the DAX to look at the 'last x weeks' or even the 'last x weeks from the selected week' DAX pretty easy. 

Average Measure = CALCULATE(AVERAGE(<FACT>), ALL(Calendar), Calendar[Week Offset Num] > -4)
lbendlin
Super User
Super User

You have a Calendar table that includes week numbers. Define what you mean by "last 4 weeks"  (does it include the current week or not?) and then write your measure accordingly. Show what you have tried.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.