Reputation: 684
I have a full DimDate dimension with all columns, and I try to filter data for ‘next week’.
I have tried:
'Date'[Week Year Week Number] = CONVERT(CONCATENATE( YEAR(TODAY() ),WEEKNUM(TODAY(),21) ),INTEGER)+1
But of course I have 2 problems:
How can I appropriately filter for ‘next week’ data?
Upvotes: 0
Views: 1241
Reputation: 2052
You can add days to TODAY with simple arithmetic: TODAY()+7
. Then you can convert the year and weeknum without special logic.
Upvotes: 1
Reputation: 4282
You can always create a calendar table where the weeknums are continuous like this which would help in filtering for next week
Calendar=
VAR _cal1 =
CALENDAR ( DATE ( 2010, 1, 1 ), DATE ( 2020, 1, 1 ) )
VAR _cal2 =
ADDCOLUMNS (
_cal1,
"weekNum",
VAR _minDate = --- what is the min date in this calendar table
MINX ( _cal1, [Date] )
VAR _x =
WEEKDAY ( _minDate, 1 ) - 1
VAR _y = _minDate - _x
VAR _z =
CEILING ( DIVIDE ( ( [Date] - _y ), 7 ), 1 ) ---[Date] - _y gives the last Sunday before the minDate in the calendar
RETURN ---from when the WEEKNUM starts
_z
)
RETURN
_cal2
Upvotes: 0