cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper I
Helper I

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!

1 ACCEPTED SOLUTION
Community Support
Community Support

Hi, @Lenerius 

 

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

Fact:

b1.png

Dim:

b2.png

 

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.

b3.png

 

Result:

b4.png

b5.png

 

Best Regards

Allan

 

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

View solution in original post

4 REPLIES 4
Helper I
Helper I

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  

Community Support
Community Support

Hi, @Lenerius 

 

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

Fact:

b1.png

Dim:

b2.png

 

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.

b3.png

 

Result:

b4.png

b5.png

 

Best Regards

Allan

 

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

View solution in original post

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! 

 

Responsive Resident
Responsive Resident

 

 

CREATE a table with 

Value , teamleader 

UNION

Value , Responsible

 

remove duplicate values

 

Link dim to second column

Link first column to Value

Helpful resources

Announcements
secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors