Forum Discussion
Help to filter Current week and next Week
How can i filter the current week
And next week.
Thanks in Advance..
Have a great day
Hi Anonymous ,
Sorry for my late respond, we can adjust the formula as below.
Column = VAR next = TODAY () + 7 VAR yn = YEAR ( next ) VAR yt = YEAR ( TODAY () ) VAR weeknumt = WEEKNUM ( TODAY (),2 ) VAR weeknun = WEEKNUM ( next,2 ) VAR wek = WEEKNUM ( 'date'[Date],2 ) RETURN IF ( OR ( yn = YEAR ( 'date'[Date] ) && weeknun = wek, yt = YEAR ( 'date'[Date] ) && weeknumt = wek&& WEEKDAY('date'[Date],2)<=5 ), "current week & next week", BLANK () )As the picture above, Sat and Sunday have been exculded for current week.
6 Replies
- AnonymousNot applicable
Anonymous Please create a calculated column as per below. If the week number is equivalent to current week number or week number one plus one then return true. you can use this column in filter.
Column = VAR _weeknum = WEEKNUM(TODAY()) RETURN IF(WEEKNUM('Table'[Date])=_weeknum||WEEKNUM('Table'[Date])= _weeknum+1,TRUE(),FALSE())- AnonymousNot applicable
Thanks
Is there any option to filter only monday to friday in current week
i.e sunday and saturday to be excluded..
According to your query week is starting from sunday how to start from monday?
- v-frfei-msftCommunity Support
Hi Anonymous ,
Sorry for my late respond, we can adjust the formula as below.
Column = VAR next = TODAY () + 7 VAR yn = YEAR ( next ) VAR yt = YEAR ( TODAY () ) VAR weeknumt = WEEKNUM ( TODAY (),2 ) VAR weeknun = WEEKNUM ( next,2 ) VAR wek = WEEKNUM ( 'date'[Date],2 ) RETURN IF ( OR ( yn = YEAR ( 'date'[Date] ) && weeknun = wek, yt = YEAR ( 'date'[Date] ) && weeknumt = wek&& WEEKDAY('date'[Date],2)<=5 ), "current week & next week", BLANK () )As the picture above, Sat and Sunday have been exculded for current week.
- amitchandakSuper User
First create a date table and join it with you fact
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.
In your date table have week number.
You can create a formula lagging seven days and it should work
before 7 day = CALCULATE(sum(Sales[Sales Amount]),dateadd('Date'[date],-7,DAY))
Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functionsAppreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p/881739
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601 - v-frfei-msftCommunity Support
Hi Anonymous ,
I have created a sample for your reference, please check the pbix as attached.
Column = VAR next = TODAY () + 7 VAR yn = YEAR ( next ) VAR yt = YEAR ( TODAY () ) VAR weeknumt = WEEKNUM ( TODAY () ) VAR weeknun = WEEKNUM ( next ) VAR wek = WEEKNUM ( 'date'[Date] ) RETURN IF ( OR ( yn = YEAR ( 'date'[Date] ) && weeknun = wek, yt = YEAR ( 'date'[Date] ) && weeknumt = wek ), "current week & next week", BLANK () ) - AnonymousNot applicable
Hi,
What if the next weeks are in the next year ? This formula doesn't seems to work correcly.. any help?
Thanks!
Formula I'm using :
Date_Filter =VAR next =TODAY () + 7VAR yn =YEAR ( next )VAR yt =YEAR ( TODAY () )VAR weeknumt =WEEKNUM ( TODAY () )VAR weeknun =WEEKNUM ( next )VAR wek =WEEKNUM ( Dim_Calendar[Calendar Date] )RETURNIF (yn = YEAR ( Dim_Calendar[Calendar Date] )&& weeknun = wek ||yt = YEAR ( Dim_Calendar[Calendar Date] )&& weeknumt = wek ||yt = YEAR ( Dim_Calendar[Calendar Date] )&& WEEKNUM(TODAY() +14) = wek ||yt = YEAR ( Dim_Calendar[Calendar Date] )&& WEEKNUM(TODAY() + 21) = wek ||yt = YEAR ( Dim_Calendar[Calendar Date] )&& WEEKNUM(TODAY() +28) = wek||yt = YEAR ( Dim_Calendar[Calendar Date] )&& WEEKNUM(TODAY() +35) = wek||yt = YEAR ( Dim_Calendar[Calendar Date] )&& WEEKNUM(TODAY() +42) = wek ,"current week & next weeks",BLANK ())