SWITCH in DAX with RELATED TABLE

alt731

New Member
Joined
Jun 28, 2017
Messages
3
I'm in Power BI trying to add a calculated column.

I've got two tables, and a join between them: 1:n.

Table 1:
ID
Description
1
Bing
2
Bang
3
Bong

<tbody>
</tbody>

Table 2:
ID
Name
1
Joe
2
Fred

<tbody>
</tbody>

I can join them together like this:

ID
Description
ID
Name
1
Bing
1
Joe
2
Bang
2
Fred
3
Bong

<tbody>
</tbody>

As we can see, ID 3 in Table 1 does not have a corresponding ID in Table2

So what I am trying to do, is add a calculated column to using a SWITCH() function to get this:


ID
Description
ID
Name
SwitchColumn
1
Bing
1
Joe
Joe
2
Bang
2
Fred
Fred
3
Bong
Bong

<tbody>
</tbody>

Here is my code:

SwitchColumn = SWITCH(RELATED('Table1'[ID]), BLANK(), 'Table2'[Name], 'Table1'[Description])

However, its not working. What DAX code should I be using here? Thanks.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Why don't you do this in Power Query just after you do the merge?

Thanks. There is no merge. I am joining the two tables together via a relationship in DAX. I guess the question is, is it possible to do what I want in DAX. I'm getting the impression that DAX can't cope with the type of logic I want, across tables.
 
Upvote 0

Forum statistics

Threads
1,214,782
Messages
6,121,532
Members
449,037
Latest member
tmmotairi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top