Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Majidbhatti
Advocate IV
Advocate IV

Multiple table relationships

Hi,

 

I have 3 tables and relations as shown below. When i do the visuals by adding all 3 tables on the page; 

Upon selecting COMPANY, DEPT and TRANS are filtered but upon selecting DEPT, it does not filter TRANS. I have tried all the possible relationship types but none seems to be working. Please help

 

Capture.PNG

 
1 ACCEPTED SOLUTION

Hi @Majidbhatti 

First, create the relationship as below:

Capture10.JPG

Since the total for all [Amount] in the [trans] table is 302, so the measure grand total should be 302,

Capture8.9.JPG

Create measures

Measure = SUM(trans[Amount])

Measure 2 =
IF (
    ISINSCOPE ( company[name] ),
    IF ( ISINSCOPE ( dept[desc] ), [Measure], SUMX ( dept, [Measure] ) ),
    SUMX ( company, [Measure] )
)

If you want the grand total to be the sum of all the subtotals, you could try the measure below

Measure 3 =
VAR c =
    CALCULATE ( DISTINCTCOUNT ( dept[desc] ), ALLSELECTED ( dept ) )
RETURN
    IF (
        ISINSCOPE ( company[name] ),
        IF ( ISINSCOPE ( dept[desc] ), [Measure], SUMX ( dept, [Measure] ) ),
        c * SUMX ( company, [Measure] )
    )

Capture9.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
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

7 REPLIES 7
v-juanli-msft
Community Support
Community Support

Hi @Majidbhatti 

Is this problem sloved? 
If it is sloved, could you kindly accept it as a solution to close this case?
If not, please let me know.
 
Best Regards
Maggie
v-juanli-msft
Community Support
Community Support

Hi @Majidbhatti 

I can reproduce the error.

Capture3.JPGCapture2.JPG

 

If you do some aggregation on some fields, it should work.

Capture1.JPG

 

If you don't like any aggregation, you just want to show all values of some columns from three tables,

you could create a new table.

Table =
CROSSJOIN (
    company,
    SELECTCOLUMNS ( dept, "id1", [area id], "code", [code] ),
    SELECTCOLUMNS ( trans, "id2", [area id], "group code", [group code] )
)

Capture4.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

@parry2k I tired the way u mentioned, but it works only on single filter selection. If i select Company it will filter other tables and similarly if i only select DEPT then other tables get filtered. My visual has Company totals and then Dept totals. Company filter should slice Dept and Dept should slice Trans.

 

@MartynRamsden I am inclined to see if combining Company and Dept would work. Will let you know.

 

@v-juanli-msft You solution works but since i am not using measures and want to use the visual filtering option. this is not working for me.

@v-juanli-msft I have changed the data in the sample file under your working. the data iin your file was not in the way it should be so i have modified the file explaining my problem. the total are all wrong and filtering is not working.

 

You can download the .pbix file here

Hi @Majidbhatti 

First, create the relationship as below:

Capture10.JPG

Since the total for all [Amount] in the [trans] table is 302, so the measure grand total should be 302,

Capture8.9.JPG

Create measures

Measure = SUM(trans[Amount])

Measure 2 =
IF (
    ISINSCOPE ( company[name] ),
    IF ( ISINSCOPE ( dept[desc] ), [Measure], SUMX ( dept, [Measure] ) ),
    SUMX ( company, [Measure] )
)

If you want the grand total to be the sum of all the subtotals, you could try the measure below

Measure 3 =
VAR c =
    CALCULATE ( DISTINCTCOUNT ( dept[desc] ), ALLSELECTED ( dept ) )
RETURN
    IF (
        ISINSCOPE ( company[name] ),
        IF ( ISINSCOPE ( dept[desc] ), [Measure], SUMX ( dept, [Measure] ) ),
        c * SUMX ( company, [Measure] )
    )

Capture9.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

MartynRamsden
Solution Sage
Solution Sage

Hi @Majidbhatti 

 

It's almost always best to avoid bi-directional relationships in your model.

 

If it's possible, I would recommend that you denormalize the Department table into the Company table.
That way, you'll have a much simpler data model (two tables and a single many to one relationship) and your filters should work perfectly.

 

If this isn't an option, your next best solution is to use CROSSFILTER in your measure to temporarily enable bi-directional filtering for the life of the calculation.

 

Best regards,
Martyn

 

parry2k
Super User
Super User

@Majidbhatti usually you write a measure for crossfilter but quickly change cross filter between Departmet and COmpany to both direction, to do so, clicking on relationship line between dept and company and lower right corner change direction to both and this will do it.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.