PowerBI:切片器以筛选表仅当选择多个值时 [英] PowerBI: Slicer to filter a table Only when more than 1 value is selected
问题描述
我有一张表格,其中包含5种类别,单位显示为2种类型,即实际和预算。
I have a table with 5 categories and units displayed into 2 types, Actual and budget.
我要过滤此表。仅在限幅器中选择2个或更多值时。这样的东西。
I want to filter this table. Only when 2 or more values are selected in the slicer. Something like this.
我虽然添加了一个量度,但不知道如何准确地运行if语句。
I though of adding a measure, but dont know how to work the if statement exactly.
Measure = IF(COUNTROWS(ALLSELECTED(Report[Shipment Group])) = 1, "Something which would not filter the units", SELECTEDVALUE(Report[Units], SUM(Report[Units])))
不知道这是正确的方法,想知道是否可以使用其他方法。任何帮助都会有所帮助。
Not sure if this is correct approach.Would like to know if any other approach is possible. Any help would be helpful. Thank you in advance.
推荐答案
这是一个奇怪的请求,但是我认为我有一些工作。
This is a bit of an odd request, but I think I have something that works.
- 首先,您需要为切片器值创建一个单独的表(否则您将无法控制所需过滤的方式)。您可以点击新表格按钮并将其定义如下:
Groups = VALUES(Report[Shipment Group])
-
将切片器设置为使用
Groups [Shipment Group]
代替Report [运输组]
。
定义新度量,如下所示:
Define your new measure as follows:
Measure = IF(COUNTROWS(ALLSELECTED(Groups[Shipment Group])) = 1,
SUM(Report[Units]),
SUMX(FILTER(Report,
Report[Shipment Group] IN VALUES(Groups[Shipment Group])),
Report[Units]))
或等效地
Measure = IF(COUNTROWS(ALLSELECTED(Groups[Shipment Group])) = 1,
SUM(Report[Units]),
CALCULATE(SUM(Report[Units]),
FILTER(Report,
Report[Shipment Group] IN VALUES(Groups[Shipment Group]))))
注意:仔细检查Power BI是否没有自动在组
和报告
表格。你不要那样。
Note: Double check that Power BI has not automatically created a relationship between the Groups
and Report
tables. You don't want that.
这篇关于PowerBI:切片器以筛选表仅当选择多个值时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!