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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
carade97
Frequent Visitor

How to show previous week data from present filtering week

Hi guys, please help me figure this problem out

I want to show previous data like this

carade97_0-1692761251561.png

carade97_1-1692761278835.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @carade97 ,

 

Here are the steps you can follow:

1. Create measure.

Flag =
var _selectyear=SELECTEDVALUE('Date'[Year])
var _selectmonth=SELECTEDVALUE('Date'[Month])
var _selectweek=SELECTEDVALUE('Date'[Week])
var _date1=
MINX(
    FILTER(ALL('Date'),
    'Date'[Year]=_selectyear&&'Date'[Month]=_selectmonth&&'Date'[Week]=_selectweek),[Date])
var _date2=
MAXX(
    FILTER(ALL('Date'),
    'Date'[Year]=_selectyear&&'Date'[Month]=_selectmonth&&'Date'[Week]=_selectweek),[Date])
return
IF(
    MAX('Table'[Date]) >=_date1-7&&MAX('Table'[Date])<=_date2-7,1,0)

2. Result:

vyangliumsft_0-1692946761706.png

 

 

Best Regards,

Liu Yang

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

2 REPLIES 2
Anonymous
Not applicable

Hi  @carade97 ,

 

Here are the steps you can follow:

1. Create measure.

Flag =
var _selectyear=SELECTEDVALUE('Date'[Year])
var _selectmonth=SELECTEDVALUE('Date'[Month])
var _selectweek=SELECTEDVALUE('Date'[Week])
var _date1=
MINX(
    FILTER(ALL('Date'),
    'Date'[Year]=_selectyear&&'Date'[Month]=_selectmonth&&'Date'[Week]=_selectweek),[Date])
var _date2=
MAXX(
    FILTER(ALL('Date'),
    'Date'[Year]=_selectyear&&'Date'[Month]=_selectmonth&&'Date'[Week]=_selectweek),[Date])
return
IF(
    MAX('Table'[Date]) >=_date1-7&&MAX('Table'[Date])<=_date2-7,1,0)

2. Result:

vyangliumsft_0-1692946761706.png

 

 

Best Regards,

Liu Yang

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

JasperDJ
Helper I
Helper I

 
I usually assign an indexnumber to a year+week number in my date table, this way I can show week 52 data when I select week 1. 
Your measure could look something like this:
Measure week -1 =
VAR MaxWeek = CALCULATE(LASTNONBLANK('Date table'[Index],1),ALLSELECTED('Date table'))
Return
CALCULATE([Your Measure],ALL('Date table'),'Date table'[Index]+1=MaxWeek)

 

Depending how the table is sorted when adding the index you might need to replace the +1 with a -1 in the return part.

Let me know if you need any more help implementing this 🙂

 

Jasper

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors