cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper III

## Filtering Data from the previous x weeks (Monday to Sunday)

Hi All,

When I filter the number of previous weeks in Query, Power BI takes one week as Sunday to Saturday. Is there a way for me to set or change it so that Power BI reads one week as Monday to Sunday? Thanks in advance for the help

Best Regards

2 REPLIES 2
Community Support

Hi @7ea8ea ,

You can create a column by WEEKNUM:

``WEEKNUM = WEEKNUM('Table'[Date],2)``

Week begins on Monday. Weekdays are numbered 1 through 7.

And you can use measure like below to filter the number of previous weeks.

``Measure = CALCULATE(SUM('Table'[column]),FILTER('Table','Table'[WEEKNUM] = WEEKNUM(Today())- selectednumber)))``

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,

Dedmon Dai

Super User

@7ea8ea , Create a date table with Week columns like these

New columns

``````Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
``````

New measures

``````This Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))
Last year Week= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=(max('Date'[Week Rank]) -52)))
``````

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

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

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors