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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
marri
Frequent Visitor

related function between three tables

Hi,

 

I have three tables say A, B and C.

Relationship Between tables are follows:

Table A has Primarykeys of B and C

B to A - One to Many

C to A - One to Many

 

Now I want to derive a column in table A (calculated column) based on the combition of some descriptive columns of B and C

For Example:  Table A.calculated col  =SWITCH(TRUE(),

                                                               tableB.title = 'abc' and tablec.code='kon', 'pi'

                                                              tableB.title='phg' and tableC.code='poj', 'lm',

                                                             ' unknown')

 

Please explain how shall i use related function for the above scenario

 

 

1 ACCEPTED SOLUTION
v-caliao-msft
Microsoft Employee
Microsoft Employee

@marri,

 

If the table relationships are created without problems. You could try the DAX below.

Table A.calculated col =
var tableBtitle = RELATED(tableB[title])
var tableCcode = RELATED(tableC[code])
return SWITCH(TRUE(),   tableBtitle  = "abc" && tableCcode ="kon", "pi",
			tableBtitle ="phg" && tableCcode ="poj", "lm",
			"unknown")

Regards,

Charlie Liao

View solution in original post

3 REPLIES 3
marri
Frequent Visitor

Hi,

 

I have three tables say A,B and C

The relationship between tables are listed below

 

Table A-B - Many to One

Table A-C - Many to One

Table A has primary key of B and C as different columns

Now I want to derive a column in table A based on the combination of values of columns of Table B and C


   For Eample:  Calculated column in table A =SWITCH(TRUE(),
                                                                                     A.title="Bc" && B.code="lo", "pf",
                                                                                    A.title="ko" && B.code="rt", "ju",
                                                                                     A.title="we","pm"
                                                                                      "Unknown"
                                                                                      )

 

Pleae explain me how to perform the above using related function

 

Thanks In Advance
                                                                    

v-caliao-msft
Microsoft Employee
Microsoft Employee

@marri,

 

If the table relationships are created without problems. You could try the DAX below.

Table A.calculated col =
var tableBtitle = RELATED(tableB[title])
var tableCcode = RELATED(tableC[code])
return SWITCH(TRUE(),   tableBtitle  = "abc" && tableCcode ="kon", "pi",
			tableBtitle ="phg" && tableCcode ="poj", "lm",
			"unknown")

Regards,

Charlie Liao

Thankyou i have followed your steps, It helped me.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.