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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
pasno
Helper II
Helper II

Help with related tables - more that one connection

Hi guys,

 

I'm stuck in a problem with related table, could you please help me with the example below?

I have:

- One calendar table that I use to filter all my values

- One table with direct costs for each customer

- One table with indirect costs for each customer

 

I'd like to put in a table a value that is direct + idirect costs splitted by month so I made some connections between my tables as below:

- Connection between costs table with the key: Customer ID

- I need to link calendar table to both costs table but I can't because I cannot have more that one active connection!

 

So with this problem my results are not correct because PBI does not sum considering date.

 

Any idea please?

 

Please find also, in the link below, my PBI sample file.

https://www.dropbox.com/t/mQQCkpCjKlUtB3ZX

Thank you very much!

 

Screenshot 2024-01-03 154115.png

1 ACCEPTED SOLUTION
v-nuoc-msft
Community Support
Community Support

Hi @pasno 

 

Power BI does not allow multiple active relationships between the same tables, but you can work around this limitation using inactive relationships and DAX measures.

 

For your question, here is the method I provided:

 

Here is the data you provided

 

"Direct costs"

vnuocmsft_0-1704782650664.png

 

"Indirect costs"

vnuocmsft_1-1704782687243.png

 

The relationship between Direct costs and Calendar is active. Create a measure to calculate direct costs, for tables with inactive relationships, you can use the "USERELATIONSHIP" function in the DAX measure for calculate indirect costs.

vnuocmsft_2-1704782948202.png

 

Here is the result

vnuocmsft_3-1704783562013.png

RESULT = 
    VAR DIRECT_VALUE = 
        SUM(
            'Direct costs'[Value]
        )
    VAR Indirect_VALUE = 
        CALCULATE(
            SUM(
                'Indirect costs'[Value]
            ), 
            USERELATIONSHIP(
                'Calendar'[Data], 
                'Indirect costs'[Date]
            )
        )
RETURN 
    IF(
        ISFILTERED('Calendar'[Data]), 
        DIRECT_VALUE + Indirect_VALUE, 
        BLANK()
    )

 

Regards,

Nono Chen

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

2 REPLIES 2
v-nuoc-msft
Community Support
Community Support

Hi @pasno 

 

Power BI does not allow multiple active relationships between the same tables, but you can work around this limitation using inactive relationships and DAX measures.

 

For your question, here is the method I provided:

 

Here is the data you provided

 

"Direct costs"

vnuocmsft_0-1704782650664.png

 

"Indirect costs"

vnuocmsft_1-1704782687243.png

 

The relationship between Direct costs and Calendar is active. Create a measure to calculate direct costs, for tables with inactive relationships, you can use the "USERELATIONSHIP" function in the DAX measure for calculate indirect costs.

vnuocmsft_2-1704782948202.png

 

Here is the result

vnuocmsft_3-1704783562013.png

RESULT = 
    VAR DIRECT_VALUE = 
        SUM(
            'Direct costs'[Value]
        )
    VAR Indirect_VALUE = 
        CALCULATE(
            SUM(
                'Indirect costs'[Value]
            ), 
            USERELATIONSHIP(
                'Calendar'[Data], 
                'Indirect costs'[Date]
            )
        )
RETURN 
    IF(
        ISFILTERED('Calendar'[Data]), 
        DIRECT_VALUE + Indirect_VALUE, 
        BLANK()
    )

 

Regards,

Nono Chen

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

 

 

audreygerred
Super User
Super User

Hello! Instead of connecting your two cost table together, create a table that has customer ID and any other dimensions related to the customer that you want. Join the Date table to Direct Costs and Indirect Costs, then join the newly added ID table to Direct Costs and Indiect Costs.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.