cancel
Showing results 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.

Helper III

## Previous Week Figure &amp; Average of Last 4 Weeks

I'm looking to add to somehow add a measure or edit the current one to show me last full week (previous week), and an average of last 4 weeks. I want to put data in to a table filter it to show previous week, and then use to average of 4 weeks to put a conditional formating with arrows up or down depending on the value. Hope this makes sense 🙂

``````View By Last X Days =
VAR
CALCULATETABLE(
'Shared Dates'
,DATESBETWEEN('Shared Dates'[Date],today()-7,today() )
)
,"In the last", "7 Days"
)

)
VAR
CALCULATETABLE(
'Shared Dates'
,DATESBETWEEN('Shared Dates'[Date], DATE( YEAR(TODAY()), MONTH(today()), 1),today() )
)
,"In the last", "Current Month"

)
return
UNION(_7days,_MTD)``````

1 ACCEPTED SOLUTION
Helper III

I found a solution that ticks 90% of the boxes, however it takes into account the last full week too, and I wanted to look 4 weeks prior the last full week.

For example we are in week 6 now (not full week), so last full week will be week 5, so the below formula should look at average of week 1,2,3 and 4, but instead its looking at 2,3,4 and 5.

``````!INC RAG2 =
VAR previousWeekDate =
TODAY () - WEEKDAY ( TODAY (), 3 )
RETURN
CALCULATE(
DISTINCTCOUNT( '1-182'[Inc No.] ),
FILTER (
'Shared Dates',
'Shared Dates'[Date] <= previousWeekDate
&& 'Shared Dates'[Date] >= ( previousWeekDate - 28 )
)
) /4``````

Also, would there be an option to ignore Report Slicer? As when I change the Date Slicer for the tab it messes up the above measure?

Edit: for future generations seeking anwer to this.
just need to put all( 'Shared Dates'), after using filter function to ignore page / visual filter.

5 REPLIES 5
Helper III

My definition of week is Monday to Sunday.

I have a table displaying last full week, so if we are in week number 6 this year it will display results for week 5.
All the values in that table come from measures.

What my goal is to have RAG status next to each value, which would indicate if the value is higher or lower than average of last 4 weeks.

For example: if the table is displaying data for week 5, the RAG status will be based on the average of weeks 1,2,3 and 4.

Super User

what is your definition of "week" ?

https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

Helper III

I found a solution that ticks 90% of the boxes, however it takes into account the last full week too, and I wanted to look 4 weeks prior the last full week.

For example we are in week 6 now (not full week), so last full week will be week 5, so the below formula should look at average of week 1,2,3 and 4, but instead its looking at 2,3,4 and 5.

``````!INC RAG2 =
VAR previousWeekDate =
TODAY () - WEEKDAY ( TODAY (), 3 )
RETURN
CALCULATE(
DISTINCTCOUNT( '1-182'[Inc No.] ),
FILTER (
'Shared Dates',
'Shared Dates'[Date] <= previousWeekDate
&& 'Shared Dates'[Date] >= ( previousWeekDate - 28 )
)
) /4``````

Also, would there be an option to ignore Report Slicer? As when I change the Date Slicer for the tab it messes up the above measure?

Edit: for future generations seeking anwer to this.
just need to put all( 'Shared Dates'), after using filter function to ignore page / visual filter.

Super User

Please show the expected outcome based on the sample data you provided.

Helper III

If you read the thread properly you will see it was solved.

Announcements

#### 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

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors