Forum Discussion
Anonymous
4 years agoNot applicable
Create a Previous Week and Current Week Slicer
Hi I am trying create a slicer which can show current week num as "Current Week" ,previous week num as "Previous Week" and rest normal week numbers. I am using below dax to create the slice...
- Anonymous4 years ago
Hi Anonymous ,
Please have a try.
Create a column.
Flag = var _currentweek=WEEKNUM(DATE(2022,1,2),1) var _countoffirstweek=COUNTX(FILTER(ALL('Fiscal Calendar'),[Fiscal Week Number(WW)]=1&&YEAR([Date])=YEAR(EARLIER('Fiscal Calendar'[Date]))),[Date]) var _week=WEEKNUM([Date],1) var _weeknum= IF([Fiscal Week Number(WW)]=1&&_countoffirstweek<7, IF(DAY([Date])<=_countoffirstweek, CALCULATE(MAX('Fiscal Calendar'[Fiscal Week Number(WW)]),FILTER(ALL('Fiscal Calendar'),[Date]=EARLIER('Fiscal Calendar'[Date])-6)),[Fiscal Week Number(WW)]),[Fiscal Week Number(WW)]) return SWITCH( TRUE(), [Fiscal Week Number(WW)]=_currentweek&&YEAR([Date])=YEAR(TODAY()),"currentweek", [Fiscal Week Number(WW)]=_currentweek-1&&YEAR([Date])=YEAR(TODAY()),"previousweek", FORMAT(_weeknum,"#"))Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
4 years agoAnonymous , You need to have columns like
start week = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1 //Monday week use for sunday WEEKDAY('Date'[Date],1)
end date= 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)//Monday week use for sunday WEEKDAY('Date'[Date],1)
Week Type = Switch( True(),
[start week]<=Today() && [end date]>=Today(),"This Week" ,
[start week]<=Today()-7 && [end date]>=Today()-7,"Last Week" ,
[Week Name]
)
Anonymous
4 years agoNot applicable
Hi
Thank you for replying but it didn't work.