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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Saadii_360
Helper I
Helper I

Show Current Week by default

Hi everyone,
so im using current week filter and all weekNo. filter on left for year 2022,2021,2020 (same weeks)  so that boss can see chose which ever weeks he like.
Need:
but he wants the current week to be showed by default. so if he opens this report he will see the current week sales for the year 2022,2021 and 2020 (same week) and use the all weekNo. filter to see the other weeks other than current.

Saadii_360_0-1643658063586.png

Problem:

Problem is that the way i have used the current filter in dax does not  allow me to use the other all weeks filter. please find below the dax code i have used for current week

SemCourante =
//Current Weeks
if(year(now())&weeknum(now()-1) = year(DMVBICalendarView1[Date])&weeknum(DMVBICalendarView1[Date],1),"Courrante",
if((year(now()))-1&weeknum(now()) = year(DMVBICalendarView1[Date])&weeknum(DMVBICalendarView1[Date],1),"Courrante-1",
if((year(now()))-2&weeknum(now()) = year(DMVBICalendarView1[Date])&weeknum(DMVBICalendarView1[Date],1),"Courrante-2",
if((year(now()))-3&weeknum(now()) = year(DMVBICalendarView1[Date])&weeknum(DMVBICalendarView1[Date],1),"Courrante-3"))))
and please find below the weeknumbers,
Saadii_360_1-1643658595114.png

If any of you can solve this problem that will be a huge help. show me a way to merge weekno. and current week in the same code or column. so current week becomes default but if user selects any weekno. it shows the values as well.
thanks in advance to this wonderful community.

 

2 REPLIES 2
ValtteriN
Super User
Super User

Hi,

To use this logic all you need to do is to add the other  weeks as a selection to the IF logic. So something like this:

if(year(now())&weeknum(now()-1) = year(DMVBICalendarView1[Date])&weeknum(DMVBICalendarView1[Date],1),"Courrante",
if((year(now()))-1&weeknum(now()) = year(DMVBICalendarView1[Date])&weeknum(DMVBICalendarView1[Date],1),"Courrante-1",
if((year(now()))-2&weeknum(now()) = year(DMVBICalendarView1[Date])&weeknum(DMVBICalendarView1[Date],1),"Courrante-2",
if((year(now()))-3&weeknum(now()) = year(DMVBICalendarView1[Date])&weeknum(DMVBICalendarView1[Date],1),"Courrante-3",weeknum(DMVBICalendarView1[Date]))))
Alternatively you can use SWITCH + TRUE for a clearer syntax:

SWITCH(TRUE(),
year(now())&weeknum(now()-1) = year(DMVBICalendarView1[Date])&weeknum(DMVBICalendarView1[Date],1),"Courrante",
year(now()))-1&weeknum(now()) = year(DMVBICalendarView1[Date])&weeknum(DMVBICalendarView1[Date],1),"Courrante-1",
year(now()))-2&weeknum(now()) = year(DMVBICalendarView1[Date])&weeknum(DMVBICalendarView1[Date],1),"Courrante-2",
year(now()))-3&weeknum(now()) = year(DMVBICalendarView1[Date])&weeknum(DMVBICalendarView1[Date],1),"Courrante-3"
weeknum(DMVBICalendarView1[Date]))


I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/






Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




No. I just want current week by default. But when i click on other weeks it should not show blank values because of the current week filter.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.