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
apelleti
Helper I
Helper I

Power BI table connections with multiple keys - RELATED returns empty

I have a question about table connections in Power BI.

 

I have a fact table with two ID fields: HCA ID and 710 ID. A row must be either an HCA or a 710 but cant be both. I created a new field Area ID that returns the HCA ID or the 710 ID depending on which applies.

 

Fact table:

Area Report

HCA ID

710 ID

Area ID (HCA or 710)

Area Shape (goal)

Area Shape (actual)

101

N/A

101

A

A

102

N/A

102

B

B

N/A

201

201

D

 

N/A

202

202

E

 

103

N/A

103

C

C

 

I have two key tables that indicate the shapes of the HCA IDs and the 710 IDs. I connected ‘Area Report’[HCA ID] to ‘HCA Shape’[HCA ID] (many to one) and connected ‘Area Report’[710 ID] to ‘HCA Shape’[710 ID] (many to one).

 

Key tables:

HCA Shape

HCA ID

Shape

101

A

102

B

103

C

 

710 Shape

710 ID

Shape

201

D

202

E

 

My goal is to Is to create the field Area Shape that puts the HCA shape and 710 shape in a column in the fact table. The issue is that when using the RELATED function, the HCA shape works but the 710 shapes return empty. I think the issue is that I have multiple keys in the fact table but I am not sure how to deal with this. 

 

Thanks in advance for any assistance! 

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

Hi , @apelleti 

According to your description, you want to get the shape name from two tables.

My test data is the same as yours and i create relationship like yours:

vyueyunzhmsft_0-1674439796152.png

We can click "New Column" and enter this :

Area Shap = IF( [HCA ID] <> "N/A" , RELATED('HCA Shape'[Shape]) ,RELATED('710 Shape'[Shape]))

Then we can meet your need , the result is as follows:

vyueyunzhmsft_1-1674439826642.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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-yueyunzh-msft
Community Support
Community Support

Hi , @apelleti 

According to your description, you want to get the shape name from two tables.

My test data is the same as yours and i create relationship like yours:

vyueyunzhmsft_0-1674439796152.png

We can click "New Column" and enter this :

Area Shap = IF( [HCA ID] <> "N/A" , RELATED('HCA Shape'[Shape]) ,RELATED('710 Shape'[Shape]))

Then we can meet your need , the result is as follows:

vyueyunzhmsft_1-1674439826642.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

bolfri
Super User
Super User

I don't know the names of your tables but I think you want something like this:

 

Area Shape =
SWITCH(TRUE(),
    NOT(ISBLANK(RELATED(hca_shape[Shape]))),RELATED(hca_shape[Shape]),
    NOT(ISBLANK(RELATED('710_Shape'[Shape]))),RELATED('710_Shape'[Shape])
)
 
Result:
bolfri_0-1674241858171.png

 





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

Proud to be a Super User!




Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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