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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
adoster
Resolver I
Resolver I

Create a new column using data from 2 other related tables

I have 3 related tables. I am trying to create a new column based on values from the other 2 tables.

 

Table A

NameOld Code
Mickey Mouse11111
Donald Duck11111
Iron Man22222
Captain America33333
Black Widow44444
Iron Man55555

 

Table B

Original CodeNew Code
1111112345
2222223456
3333334567
4444445678
5555556789

 

Table C

NameTypeCode
Mickey MouseDisney77777
Donald DuckDisney77777
SupermanDC Comics88888
Iron ManMarvelSee Table B
Captain AmericaMarvelSee Table B
Black WidowMarvelSee Table B

 

Something similar to:

IF ('Table C'[Type] = "Marvel" THEN 'Table B'[New Code]) ,  ELSE 'Table C'[Code]

 

Here are the reulst for these sample Tables

NameOriginal CodeNEW Code Results
Mickey Mouse1111177777
Donald Duck1111177777
Superman2222288888
Iron Man2222223456
Captain America3333334567
Black Widow4444445678
Iron Man5555556789

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@adoster Maybe:

Column = 
  IF (RELATED('Table C'[Type]) = "Marvel", RELATED('Table B'[New Code]),RELATED('Table C'[Type]))

Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Super User
Super User

@adoster Maybe:

Column = 
  IF (RELATED('Table C'[Type]) = "Marvel", RELATED('Table B'[New Code]),RELATED('Table C'[Type]))

Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.