Forum Discussion
Creating conditional relationships in power bi
I have 2 tables that I would like to create a relationship between.
I have Column A in both table 1 and table 2 and would like to create a relationship on this column. However, in Table 2, Column A is often null. If it is null, I would like to create a relationship between Column B in table 1 and Column B in table 2. Is this possible in power bi? The goal is the get Column A, Column B, Value and NurseName in one table.
I have created an example below.
Table 1:
| Column A | Column B | Value |
| 001 | AA1 | 109 |
| 002 | BB1 | 123 |
| 003 | CC1 | 983 |
| 004 | DD1 | 821 |
Table 2:
| Column A | Column B | NurseName |
| 001 | null | Alex |
| null | BB1 | Ally |
| 003 | null | John |
| null | DD1 | Tanya |
- Anonymous3 years ago
Hi allora ,
Please create a new calculated column.
NurseName = IF ( COUNTROWS ( RELATEDTABLE ( 'Table 2' ) ), CALCULATE ( MAX ( 'Table 2'[NurseName] ), RELATEDTABLE ( 'Table 2' ) ), CALCULATE ( MAX ( 'Table 2'[NurseName] ), USERELATIONSHIP ( 'Table 1'[Column B], 'Table 2'[Column B] ) ) )Best Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
1 Reply
- AnonymousNot applicable
Hi allora ,
Please create a new calculated column.
NurseName = IF ( COUNTROWS ( RELATEDTABLE ( 'Table 2' ) ), CALCULATE ( MAX ( 'Table 2'[NurseName] ), RELATEDTABLE ( 'Table 2' ) ), CALCULATE ( MAX ( 'Table 2'[NurseName] ), USERELATIONSHIP ( 'Table 1'[Column B], 'Table 2'[Column B] ) ) )Best Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum