Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Filter table from another table with multiple relationships

I need help figuring out how I can filter a FactTable with a DimTable, where one column in the DimTable is related to two columns in the FactTable.

If I filter a value in the DimTable, I want all rows in FaceTable that matches on at least one of the columns.

 

Example:

I create relationship between Teamleader and Person AND between Responsible and Person. 

If i filter on value C DimTable, I want all rows in FactTable that has C in either Teamleader or Responsible (or both). 

 

FactTable: 

Value

Teamleder

Responsible

10

A

A

10

B

A

5

C

B

20

A

C

20

B

B

15

C

A

 

DimTable:

Person

A

B

C

 

Thank you so much in advance!

  • Hi, Anonymous 

     

    Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

    Fact:

    Dim:

     

    There is no relationship between two tables. You may create a measure as below.

    Visual Control = 
    IF(
        MAX('Fact'[Teamleader]) in DISTINCT(Dim[Person]) || MAX('Fact'[Responsible]) in DISTINCT(Dim[Person]),
        1,0
    )

     

    Then you need to put the measure in the visual level filter and use 'Person' from 'Dim' table to filter the result.

     

    Result:

     

    Best Regards

    Allan

     

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

4 Replies

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

    Hi, Anonymous 

     

    Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

    Fact:

    Dim:

     

    There is no relationship between two tables. You may create a measure as below.

    Visual Control = 
    IF(
        MAX('Fact'[Teamleader]) in DISTINCT(Dim[Person]) || MAX('Fact'[Responsible]) in DISTINCT(Dim[Person]),
        1,0
    )

     

    Then you need to put the measure in the visual level filter and use 'Person' from 'Dim' table to filter the result.

     

    Result:

     

    Best Regards

    Allan

     

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi! I think I made my example above a little too simple. What I actually have is a FactTable with the following columns: Date, Value, ID, Teamleader, Responsible. 

       

      And I would like to create a column chart that has year and month on the x-axis. And I have the following measue as value: calculate(Distinctcount(FactTable[ID]))

       

      How can I filter the column chart if I want to count number of ID during a month that has person A as either responsible or Teamleader? 

       

      The solution above works great when filtering a table with unique ID on each row. But when I aggregate I get problem. 

       

      Grateful for your fantastic help as always! Thanks! 

       

  • Anonymous's avatar
    Anonymous
    Not applicable

     

     

    CREATE a table with 

    Value , teamleader 

    UNION

    Value , Responsible

     

    remove duplicate values

     

    Link dim to second column

    Link first column to Value

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Allan! Thank you so much for the quick and great response! This was perfect for filtering the table just like I wanted. But, why doesnt it work when i have a colum chart visual and want to for example visualize sum of value? 

    Thanks again! v-alq-msft