DAX 查询中的多个过滤器

问题描述 投票:0回答:0

在 Power BI Report Builder 中,以 Power BI 数据集作为数据源,如何编写具有多个过滤器的查询,其中一些过滤器是可选的?

例子:

在报告中,用户可以选择这些参数:

  • CustomerID(可选)
  • AffiliateID(可选)
  • PaymentDateFrom(必填项)
  • PaymentDateTo(必填)

在 SQL 中,我是这样做的:

SELECT 
    *
FROM 
    Temp
WHERE 
    PaymentDate >= @P_PaymentDateFrom
    and PaymentDate <= @P_PaymentDateTo
    and IIF(@P_CustomerID = '', 1, CustomerID) = IIF(@P_CustomerID = '', 1, @P_CustomerID)
    and IIF(@P_AffiliateID = '', 1, AffiliateID) = IIF(@P_AffiliateID = '', 1, @P_AffiliateID)

但是如何在 DAX 中做到这一点?

powerbi dax reportbuilder3.0
© www.soinside.com 2019 - 2024. All rights reserved.