简体   繁体   English

使用 DAX 基于 power bi 中的切片器选择创建新表

[英]creating new table based on slicer selection in power bi using DAX

I am new in Power Bi, so if anyone help in the following scenario then it will be very helpful for me.我是 Power Bi 的新手,所以如果有人在以下情况下提供帮助,那对我来说将非常有帮助。

suppose i have two tablse as Table 1 = |假设我有两个表,如表 1 = | Name |名称 | | | -----| ------| | | A |一个 | | | B |乙 | | | C | C |

and Table 2 = |Sl.和表2=|S1。 No |否 | Name |名称 | |-------| |------| -----| ------| | | 1 | 1 | A |一个 | | | 2 | 2 | B |乙 | | | 3 | 3 | C | C |

Now, I will put Table 1 in the slices visualization and it will have multiple selections.现在,我将表 1 放入切片可视化中,它将有多个选择。 Using the slices selection, I want to create a new table that filters Table 2 using DAX.使用切片选择,我想创建一个使用 DAX 筛选表 2 的新表。 For eg suppose I select the rows with names "B" and "C".例如,假设我 select 名称为“B”和“C”的行。 I am expecting the return table as follows: |Sl.我期望返回表如下:|Sl。 No |否 | Name |名称 | |-------| |------| -----| ------| | | 2 | 2 | B |乙 | | | 3 | 3 | C | C |

I have tried the following DAX but did not get the required result我尝试了以下 DAX 但没有得到所需的结果

selected list = var selected_list= ALLSELECTED(Table 1[Name]) return CALCULATETABLE('Table 2', FILTER('Table 2', CONTAINSROW(selected_list, 'Table 2'[name])))选定列表 = var selected_list= ALLSELECTED(Table 1[Name]) return CALCULATETABLE('Table 2', FILTER('Table 2', CONTAINSROW(selected_list, 'Table 2'[name])))

You can't create a physical table based on slicer selection.您不能根据切片器选择创建物理表。 It's not possible.这是不可能的。

All physical tables should be evaluated by DAX before they are uploaded to a data model or refreshed.所有物理表在上传到数据 model 或刷新之前都应该通过 DAX 评估。

You can create only a virtual table with slicers values, but you cant RETURN it as a result of the measure.您只能创建一个带有切片器值的虚拟表,但您不能将其作为测量结果RETURN You can use this virtual table for intermediate calculations, but a measure that uses slicers values should return Scalar value, not a table.您可以将此虚拟表用于中间计算,但使用切片器值的度量应返回Scalar量值,而不是表。 To get all values from the slicer like this:要像这样从切片器获取所有值:

VALUES('Table 2'[name]) 

but it should be a correct syntax in the measure.但它应该是度量中的正确语法。

If you want to make a visual named Table or Matrix then can do following steps:如果你想制作一个名为TableMatrix的视觉对象,可以执行以下步骤:

  1. Link tables in your data mode Table 1 and Table 2 .在您的数据模式中链接表Table 1Table 2 Table 1 should filter Table 2 like this Table 1 -> Table 2 (link Table 1[Name] and Table 2[Name] columns). Table 1应像这样过滤Table 2 Table 1 -> Table 2 (链接Table 1[Name]Table 2[Name]列)。
  2. Then create a slicer of Table 1[Name] .然后创建Table 1[Name]的切片器。
  3. Choose your value/values.选择您的价值观。

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

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