PowerBI:切片器仅在选择超过1个值时才能过滤表

编程入门 行业动态 更新时间:2024-10-23 11:25:06
本文介绍了PowerBI:切片器仅在选择超过1个值时才能过滤表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个表格,其中包含 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[Shipment Group].

    如下定义您的新度量:

    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 是否未在 Groups 和 Report 表之间自动创建关系.你不想这样.

    Note: Double check that Power BI has not automatically created a relationship between the Groups and Report tables. You don't want that.

  • 更多推荐

    PowerBI:切片器仅在选择超过1个值时才能过滤表

    本文发布于:2023-10-30 19:19:27,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1543755.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:切片   时才   PowerBI

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!