如何在dax中过滤下周的数据?

How to filter data for next week in dax?

我有一个包含所有列的完整 DimDate 维度,我尝试过滤“下周”的数据。

我试过:

'Date'[Week Year Week Number] = CONVERT(CONCATENATE( YEAR(TODAY()  ),WEEKNUM(TODAY(),21)    ),INTEGER)+1     

当然我有两个问题:

如何适当地过滤“下周”数据?

您始终可以创建一个日历 table,其中周数像这样连续,这有助于过滤下周

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

您可以使用简单的算术将今天添加到今天:TODAY()+7。然后你就可以不用特殊逻辑转换年和周数了。