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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Using Inactive Relationship to Fill Gaps in Data

Hello Everyone,

 

I am trying to use an inactive relationship to fill gaps in my data. I have a fact table and a dimension table. There are two relationships, 1 active and 1 inactive, pictured below:

 

chasedalton_1-1608224810385.png

 

In my data table (Data), there are 2 columns: Contract # and Contract Collective #. My Dimension table (Contract Header) is joined to the Contract # so I can pull in the customer and vendor information associated with the Contract #. The combined data looks like the left table below (right table is my dimension table):

 

chasedalton_4-1608224989522.png

 

Note how on the bottom row, the Contract # and Contract Collective # don't match. What I want to do is that when the Contract # and Contract Collective # don't match and a null is returned for the vendor, I want to use the inactive relationship (which is based on Contract Collective #) to return the vendor for the Contract Collective # (which would be Samm's Club in this case). Can anyone help with this? 

 

 

 

 

11 REPLIES 11
parry2k
Super User
Super User

@Anonymous good to hear, I would recommend pasting the solution so that others I can get help from it.s



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.

parry2k
Super User
Super User

@Anonymous share using one drive/google drive



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.

Anonymous
Not applicable

It's all good, I found a solution!

parry2k
Super User
Super User

@Anonymous add a new column like this as an example for a vendor. 

 

In my example, the Customer represents your Contract Header table and the Table represents your data table.

 

Vendor 1 = 
VAR __vendor = RELATED ( Customer[Vendor] )
VAR __vendorIfBlank = 
IF ( COALESCE( __vendor, "" ) = "", 
    MAXX ( 
        Customer, 
        CALCULATE ( 
            MAX ( Customer[Vendor] ), 
            USERELATIONSHIP ( Customer[Column1], 'Table'[Col2]  ) 
        ) 
    ),
    __vendor 
)
RETURN __vendorIfBlank 

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!



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.

Anonymous
Not applicable

I tried it, and I was unable to use COALESCE so I just used ISBLANK instead. This is what happened when I tried it:image.png 

 

Anonymous
Not applicable

I changed my data table titles to match your use of them 

 

Hi @Anonymous,

For your scenario, I think it may cause the 'circular dependency' reference issue due to the two relationships(activated and inactivated) mapping conflict.

In my opinion, I'd like to suggest you use all functions to ignore the filter and manually apply the filter to your expressions, it may avoid the 'circular dependency' issue.

Managing “all” functions in DAX: ALL, ALLSELECTED, ALLNOBLANKROW, ALLEXCEPT 
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

how so?

Hi @Anonymous,

Can please share a pbix file with some dummy data with a similar data structure as the raw table structures? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

How do I add a file? I have a pbix, but I don't see an option to share it?

HI @Anonymous,

You can upload your file to onedrive for business and share the link here.

Notice: do not attach sensitive in the sample file.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.