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
Anonymous
Not applicable

Table with last 4 weeks data

Hello all
I have a table with week number, Sales, Costs and profits.
I would love to see, only the last 4 weeks, like this example, which are filtered from the date filter:
Capture.JPG
Thanks in advance guys
Best regards

Pedro

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

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

11 REPLIES 11

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.