日期过滤器不能作为DAX代码的一部分

时间:2019-06-20 21:29:13

标签: date filter powerbi

我有如下所示的DAX,如下所示,除了DAX中的日期过滤参数外,它还可以正常工作,我通过在时间(参数)上增加一个步骤来构建DAX,但是当我添加日期过滤元素并尝试超链接到已发布的pbix文件,它将重新设置所有过滤器,因此不应用任何过滤器。

Internet Research Report Filter =
VAR oL = "DIMSalesPerson/OfficeLocation eq '"
        & SELECTEDVALUE ( 'DIMSalesPerson'[OfficeLocation] ) & "'"
VAR oC = 
    "DIMSalesPerson/City eq '" & SELECTEDVALUE ( 'DIMSalesPerson'[City] ) & "'"
VAR oS =
    "DIMShipper/ShipCompanyName eq '"
        & SELECTEDVALUE ( 'DIMShipper'[ShipCompanyName] ) & "'"
VAR oP =
    "DIMProduct/CategoryName eq '" & SELECTEDVALUE ( 'DIMProduct'[CategoryName] ) & "'"
VAR oSP =
    "DIMSalesPerson/SalesPerson eq '"
        & SELECTEDVALUE ( 'DIMSalesPerson'[SalesPerson] ) & "'"
VAR oRegion =
    "DIMSalesPerson/SalesRegion eq '"
        & SELECTEDVALUE ( 'DIMSalesPerson'[SalesRegion] ) & "'"
VAR oDatefilter =
    IF (
        ISFILTERED ( 'Calendar'[Date] ),
        "Calendar/Date le " & MAX ( 'Calendar'[Date] ) & " and Calendar/Date ge "
            & MIN ( 'Calendar'[Date] )
    )
RETURN
    [Report URL]
        & SWITCH (
            TRUE,
            ISFILTERED ( 'DIMSalesPerson'[OfficeLocation] )
                && ISFILTERED ( 'DIMSalesPerson'[City] ), "?filter=" & oL & " and " & oC & " and " & oS & " and " & oP & " and " & oSP & " and " & oRegion & " and " & oDatefilter,
            ISFILTERED ( 'DIMSalesPerson'[OfficeLocation] ), "?filter=" & oL,
            ISFILTERED ( 'DIMSalesPerson'[City] ), "?filter=" & oC,
            ISFILTERED ( 'DIMShipper'[ShipCompanyName] ), "?filter=" & oS,
            ISFILTERED ( 'DIMProduct'[CategoryName] ), "?filter=" & oP,
            ISFILTERED ( 'DIMSalesPerson'[SalesPerson] ), "?filter=" & oSP,
            ISFILTERED ( 'DIMSalesPerson'[SalesRegion] ), "?filter=" & oRegion,
            IF (
                ISFILTERED ( 'Calendar'[Date] ),
                "Calendar/Date le " & MAX ( 'Calendar'[Date] ) & " and Calendar/Date ge "
                    & MIN ( 'Calendar'[Date] )
            )
        )

日期过滤器将根据pbix文件中日期过滤器上的最大日期和最小日期选择来工作。

1 个答案:

答案 0 :(得分:0)

为了使上述日期生效,日期必须在超级查询中采用“ YYYY-MMM-DD”格式,或使用格式([Calander [Dates],“ YYYY-MM-DD”作为新的度量是我发现的。