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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
g_georgiev444
Helper I
Helper I

How to make slicer automatically select Current, previous and next weeks?

Hello, I have a duplicated Timestamp column that is transformed to Week of Year. I use that column as a slicer. Because I need to make a custom URL I want to set up the Week column inside Power Bi to show only current week, previous week and next week. How can I do that?

 

g_georgiev444_0-1669628212753.pngg_georgiev444_1-1669628235906.png

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

Hi @g_georgiev444 ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1669684719100.png

Then apply the measure to the slicer's filter:

Measure = 
var _a = WEEKNUM(TODAY(),2)
return IF(MAX('Table'[Week of Year])>=_a-1&&MAX('Table'[Week of Year])<=_a+1,1,0)

vjianbolimsft_2-1669684934520.png

Final output:

vjianbolimsft_1-1669684916888.png

Best Regards,

Jianbo Li

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
v-jianboli-msft
Community Support
Community Support

Hi @g_georgiev444 ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1669684719100.png

Then apply the measure to the slicer's filter:

Measure = 
var _a = WEEKNUM(TODAY(),2)
return IF(MAX('Table'[Week of Year])>=_a-1&&MAX('Table'[Week of Year])<=_a+1,1,0)

vjianbolimsft_2-1669684934520.png

Final output:

vjianbolimsft_1-1669684916888.png

Best Regards,

Jianbo Li

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

Hello @v-jianboli-msft 

 

EDIT:Bottom.

 

Thank you a lot for this!

 

There is something which is confusing me quite a lot. I made it work with -2 instead of -1 which is really strange. If I let it as -1 then it does not show week 47 for some reason. Do you have an idea why this might be the case? I suppose it might be due to different start of week count, but for me it is week 48 now and I only saw 48 and 49, but with same settings you saw 48, 49 and 50.

g_georgiev444_0-1669713931244.png

 

Also, once I added the Measure to the Slicer I had to add it to the visuals as well, or they would continue to show all data.

Slicer filter:

g_georgiev444_1-1669714073223.png

Visual filter:

g_georgiev444_2-1669714139620.png

 

EDIT: I had to reload everything and now I get a different result. I see week 50 as well. I guess this is because PowerBI counts the weeks with 1 forward from what we expect as a result. I will just adjust the + and - in the Measure.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.