cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Microsoft
Microsoft

Re: Table with last 4 weeks data

Hi @pedromooji ,

 

We can use two ways to meet your requirement.

 

1. Create a calculate column first to get the week number.

 

week = RIGHT('Table'[year&week],LEN('Table'[year&week])-FIND("-",'Table'[year&week],1,1))

 

Table 1.jpg

 

Then we can create a measure based on [week].

 

Measure = 
var last_week = MAXX(ALLSELECTED('Table'),'Table'[week])
var Last_four_week = last_week-4
return 
CALCULATE(SUM('Table'[values]),FILTER('Table','Table'[week]>Last_four_week && 'Table'[week]<=last_week))

 

And we can put the [year & week] and [Measure] in a table visual.

 

Table 2.jpg

 

2. We can use Filters on this visual to get the result.

 

Also we need the week number column.

Then we create a table and configure the [year & week]’s filter and put the [week] on By value.

 

table 3.jpg

 

The result like this,

 

table 4.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?
BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

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

View solution in original post

Highlighted
Helper V
Helper V

Re: Table with last 4 weeks data

Hi @v-zhenbw-msft 
Many thanks for your solution. It's the only one that works the way that i want,....but i've already decided for your second solution.
The first one, works also, i've tried it.
THank you so much
Best regards
Pedro

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors