本文介绍了基于另一个切片器选择的 Power BI 切片器的初始值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当上类别切片器值发生变化时,我想设置下类别切片器的初始值.假设我们有这些数据:

I would like to set up initial value of lower category slicer whenever upper category slicer value changes. Suppose we have this data:

+----------------+----------------+-------+
| upper category | lower category | units |
+----------------+----------------+-------+
| fruit          | apple          |     1 |
| fruit          | banana         |     1 |
| vegetable      | carrot         |     1 |
| vegetable      | potato         |     1 |
+----------------+----------------+-------+

我们在报表中添加了两个切片器视觉效果.它看起来像这样:

We add two slicer visuals to the report. It looks like this:

我想要的结果是这样的:每当用户从上面的类别中选择fruit,然后从较低的类别切片器中选择apple.所以我们最终得到了这个:

My desired results are this: Whenever the user selects fruit from upper category, then apple is selected from lower category slicer. So we end up with this:

现在我们点击上类切片器中的vegetable,自动选择carrot作为下类切片器的初始过滤值.所以我们最终得到了这个:

Now the we click on vegetable in upper category slicer, and automatically carrot is selected as an initial filter value of lower category slicer. So we end up with this:

总结:

  1. 无论选择何种下级切片器,上层类别切片器都会显示所有项目.
  2. 根据上层类别切片器的选择,下层类别切片器仅显示适用的项目.
  3. 从上类切片器中选择项目后,总是选择下层类切片器的一个初始适用值.

谷歌搜索后,我发现这是一个很有希望的解决方案线索:https://www.kasperonbi.com/embed-your-power-bi-report-with-predefined-filters/

After googling I have found this as a promising clue to the solution:https://www.kasperonbi.com/embed-your-power-bi-report-with-predefined-filters/

我不必拘泥于切片器的视觉效果.它可能是别的东西.我想要的是保持这个功能.我可以想象它可以通过这里表达的概念用 R visual 来完成:https://dataveld.com/2016/02/10/r-visuals-in-power-bi-beyond-plots/

I do not have to stick to slicer visual. It could be something else. What I want is to maintain this functionality. I could imagine that it could be accomplished with R visual by the concept expressed here: https://dataveld.com/2016/02/10/r-visuals-in-power-bi-beyond-plots/

为方便起见,这是一个起始表代码:

Here is a start table code for your convenience:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSisqzSxR0lFKLCjISQXShkqxOgjRpMQ8IIQLl6Wmp5YkJoEVJicWFeWXYJUqyC9JLMmHSMUCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"upper category" = _t, #"lower category" = _t, units = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"upper category", type text}, {"lower category", type text}, {"units", Int64.Type}})
in
    #"Changed Type"

推荐答案

我认为目前默认切片器无法实现这一点,因为无法以编程方式设置切片器选择,但 这个相关的想法 是一个受欢迎的请求,目前正在审核中".

I don't believe this is currently possible with the default slicer as there is no way to programmatically set a slicer selection, but this related idea is a popular request that is currently "under review".

这篇关于基于另一个切片器选择的 Power BI 切片器的初始值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 19:55