简体   繁体   中英

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.

suppose i have two tablse as Table 1 = | Name | | -----| | A | | B | | C |

and Table 2 = |Sl. No | Name | |-------| -----| | 1 | A | | 2 | B | | 3 | C |

Now, I will put Table 1 in the slices visualization and it will have multiple selections. Using the slices selection, I want to create a new table that filters Table 2 using DAX. For eg suppose I select the rows with names "B" and "C". I am expecting the return table as follows: |Sl. No | Name | |-------| -----| | 2 | B | | 3 | C |

I have tried the following DAX but did not get the required result

selected list = 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.

You can create only a virtual table with slicers values, but you cant RETURN it as a result of the measure. You can use this virtual table for intermediate calculations, but a measure that uses slicers values should return Scalar value, not a table. 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:

  1. Link tables in your data mode Table 1 and Table 2 . Table 1 should filter Table 2 like this Table 1 -> Table 2 (link Table 1[Name] and Table 2[Name] columns).
  2. Then create a slicer of Table 1[Name] .
  3. Choose your value/values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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