Forum Discussion
Anonymous
4 years agoNot applicable
DAX help for a Restricted Measure
Dear Experts
I have the YearWeek, Sales and some more fields coming from 4 different tables. I want to display in a new column the last 6 weeks sales figure based on System Week.
This is basically restricting the sales value for the latest 6 weeks.
I want to achieve this using a measure. Please can someone help me with the DAX code to help me achieve this.
Kind regards
Mahad
Hi Anonymous
Please tryLast 6 Weeks Sales = VAR CurrentYearWeek = SELECTEDVALUE ( TableName[YearWeek] ) VAR TodayYearWeek = YEAR ( TODAY () ) * 100 + WEEKNUM ( TODAY () ) VAR StartYearWeek = TodayYearWeek - 6 RETURN IF ( CurrentYearWeek <= TodayYearWeek && CurrentYearWeek > StartYearWeek, [Sales Amount] )
2 Replies
- tamerj1
Community Champion
Hi Anonymous
Please tryLast 6 Weeks Sales = VAR CurrentYearWeek = SELECTEDVALUE ( TableName[YearWeek] ) VAR TodayYearWeek = YEAR ( TODAY () ) * 100 + WEEKNUM ( TODAY () ) VAR StartYearWeek = TodayYearWeek - 6 RETURN IF ( CurrentYearWeek <= TodayYearWeek && CurrentYearWeek > StartYearWeek, [Sales Amount] ) - davehus
Memorable Member
Hi Anonymous , Do you have a sanitised version of your report you could share? You could achieve this with DATESINPERIOD and a workaround as DIP only uses, days, months or years in the formula.