简体   繁体   English

Power BI:将切片器值添加到表中

[英]Power BI: add slicer value into table

My data model has one table, Tbl . 我的数据模型有一个表Tbl It has a few fields including F1 . 它有几个字段,包括F1

On my page, there is a slicer (filter) on F1 . 在我的页面上, F1上有一个切片器(过滤器)。 I want to build a measure that returns the filtered value for F1 and add it to a table visual. 我想建立一个返回F1过滤后值的度量,并将其添加到可视表中。

The visual would look as such: 视觉效果如下所示:

F1 (all values) | F1 (filtered value)

How can I do this? 我怎样才能做到这一点?

This is a bit tricky since you want the slicer to affect one column but not the other. 这有点棘手,因为您希望切片器影响一列而不影响另一列。

What I would do is create a new table to use in a slicer. 我要做的是创建一个新表以在切片器中使用。

Modeling > New Table: Slicer = VALUES(Table1[F1]) 建模>新表: Slicer = VALUES(Table1[F1])

Then use Slicer[F1] for you slicer instead of Table1[Slicer] and define a measure 然后为您的切片器使用Slicer[F1]而不是Table1[Slicer]并定义一个度量

Selected F1 = MAX(Slicer[F1])

(You can use a different function like LASTNONBLANK or SELECTEDVALUE instead of MAX if you prefer.) (如果愿意,可以使用LASTNONBLANKSELECTEDVALUE类的其他函数代替MAX 。)

Then if you set up your table with Table1[F1] and [Selected F1] , it should look like this: 然后,如果使用Table1[F1][Selected F1]设置表,则它应如下所示:

切片机选择

Let's call the measure that returns the filtered value Ms1. 我们称之为返回过滤值Ms1的度量。 If you want another measure that will not be impacted by the slicer and calculated on all Values of F1, then you will want to use the ALL function. 如果要使用不受限幅器影响并根据F1的所有值计算的其他度量,则将需要使用ALL函数。 The new measure Ms2 would look like this : 新度量Ms2将如下所示:

Ms2 = Calculate([Ms1],ALL(Table[F1])) Ms2 =计算([Ms1],ALL(表[F1]))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM