如何确定是否筛选了多个列

How to find out if more than one column is filtered

提问人:jcoke 提问时间:11/14/2023 更新时间:11/14/2023 访问量:29

问:

假设我有一个名为 and 的表,我编写了一个 DAX 代码,该代码使用该表获取总数,另一个代码从该表中获取总数。CampaignsRangeCampaignsCampaignsRangeCampaigns

我想做的是,如果它已经自行过滤,它应该显示,但是,如果它没有被过滤(或者它与任何其他过滤器一起过滤),它应该显示Campaign slicerMeasure 1Measure 2

enter image description here

例: 如果过滤了 Campaign 和 range_group,则应返回Measure 2 value (Total Avg Bays)

当前代码:

testCode = 
IF ( ISFILTERED('Campaign Table'[campaign]) = TRUE(),
    SUMX (
        SUMMARIZE ( range_plans, range_plans[branch] ,range_plans[range_name], range_plans[number_bays]),
        range_plans[number_bays]
    ),
    [Total Avg Bays])

问题:

筛选range_group时,它不会更改,但我不想显式检查该切片器是否已筛选 我想动态检查是否筛选了任何其他列,以确定要显示的值

DAX 筛选 powerbi-desktop

评论


答:

1赞 Sam Nseir 11/14/2023 #1

尝试如下操作:

testCode = 
  var onlyCampaignFiltered =
    ISFILTERED('Campaign Table'[campaign]) &&
    NOT CALCULATE(ISCROSSFILTERED('range_plans'), REMOVEFILTERS('Campaign Table'[campaign]) )

  RETURN IF(onlyCampaignFiltered,
    SUMX (
      SUMMARIZE ( range_plans, range_plans[branch] ,range_plans[range_name], range_plans[number_bays]),
      range_plans[number_bays]
    ),
    [Total Avg Bays]
  )