Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Select Table rows based on another Table

Hi All,

 

I have the below requirement. Please check and help

 

I have 2 Tables ,Table 1 and Table 2 and i have requirment. when a row in Table 1 is selected, ONLY Matching values (Names)of Table 2 should be displayed. Ex: if i select any row which has Name=James in Table1, the Values which matches James in Table 2 should be selected and displayed,

Table 1:

NameAmountDateStatus
james20001/10/2000Approved
james10010/11/2000rejected
james12008/12/2000Approved
james500020/03/2021Approved
james150013/04/2021Approved
Ajay20001/10/2020Approved
Ajay210010/11/2000rejected
Ajay25008/12/2000Approved
Ajay1500020/03/2021Approved
Ajay250013/04/2021Approved
Ajay150015/04/2021rejected

 

Table 2:

NameYearApproved Amount
James20203200
James20216500
Ajay20204500
Ajay202117500

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Anonymous Use a relationship between the two tables. If necessary, create a bridge table Table = DISTINCT('Table 1'[Name])

  • Mohammad_Refaei's avatar
    Mohammad_Refaei
    Solution Specialist

    You can create a many-to-many relationship between the name fields with bi-directional filtering thoug it is not the best approach.

    It is better to create a name table and use it as attached

  • v-chenwuz-msft's avatar
    v-chenwuz-msft
    Community Support

    Hi Ajay,

     

    There two ways to solve this question. Creating a relationship or using measure

     

    A:creating a relationship

    you can create a relationship between these tables and you can follow along with my steps.

    1 after you create these tables you need, go to the model view

     

    Under the home tab, select the Manage relationships

     

    2 Then it will show the manage relationship windows and click new icon.

    3 In the Create relationship dialog box, in the first table drop-down list, select a table. Select the column you want to use in the relationship.

    4 In the second table drop-down list, select the other table you want in the relationship. Select the other column you want to use, and then elect OK.

     

    5 then go to the report view, create two table visuals like these.

     

    Under such conditions, if you select any row which has Name=James in Table1, the Values which matches James in Table 2 should be selected and displayed.

     

    If you would like to know more about how to create and manage relationships, please see the following articles.

    https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-create-and-manage-relationships

     

    B:using a measure

    Prerequisites: there no relationship between these tables.

    1 After you create table, create a new measure

    Measure 1 =

                Var _x=selectedvalues(table 1[Name])

                Return

                If( _x=max(table[Name]),1,0)

    2 then put Measure 1 into table 2s Filters, setting the Measure 1 show items when the value is 1 as the following image show and apply filter.

     

    3 Then you select any one of name in table 1, the table 2 will display matched name in table 2.

     

     

     

    Best Regards

    Community Support Team _ chenwu zhu

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • dmf's avatar
      dmf
      Frequent Visitor

      I want to add this does not work for table visuals. The tables must be queries themselves and not a visual table for this to work.