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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
Anonymous
Not applicable

Conditional Column from Multiple Tables

Hi All, 

 

I have 4 tables : Main, Chq, Cash, ETRF and lookinto create Custom Column in Main Table.

 

Custom Column in Main Table:

 

Return "Cash" if Acc_no is in Cash Table 

 

Return "Chq" if Acc_no is in Chq Table 

 

Return "ETRF" if Acc_no is in ETRF Table 

 

Chq, Cash, ETRF tables contain Acc_no and linked to Main Table which has Acc_no too

 

What is the best way to generate results?

 

Thanks in Advance

5 REPLIES 5
AllisonKennedy
Community Champion
Community Champion

If I understand your problem correctly you should be able to try something like this, depending on how your relationships are setup:

 

Custom Column = IF(RELATED(CashTable[Acc_no])=MainTable[Acc_no], "Cash", 

IF(RELATED(ChqTable[Acc_no])=MainTable[Acc_no], "Chq",

IF(RELATED(ETRFTable[Acc_no])=MainTable[Acc_no], "ETRF",

"")))

 

Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 

 

If you found this post helpful, please give Kudos.

I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

https://sites.google.com/site/allisonkennedycv


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

HotChilli
Community Champion
Community Champion

A custom column in the fact table something like this maybe:

whichDim = SWITCH (TRUE(),
    NOT ISBLANK( RELATED(TableDim1[accnum])), "Dim1", 
    NOT ISBLANK( RELATED(TableDim2[accnum])), "Dim2",
    NOT ISBLANK( RELATED(TableDim3[accnum])), "Dim3", "n/a")

with your versions of tablenames and strings

 

Anonymous
Not applicable

Thank you so much. Custom Column query is recognising only one table : TableDim1

 

Main Table:Table Dim1 Relationship *.1 

 

Main Table:Table Dim2 Relationship 1.*

 

 Main Table:Table Dim3 Relationship 1.*

 

Do you know why? I believe the error is because how relationship is set up. 

 

It is most likely due to cross filter direction. The arrows need to point to your main table in all three relationships for this to work. Since your relationships are 1 to many and many to 1, this doesn't happen for all of them by default. You can change the cross-filter direction to both, just read up on that a bit as it may have some other impact on other data in your visualizations. 

 

 

Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 

 

If you found this post helpful, please give Kudos.

I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

https://sites.google.com/site/allisonkennedycv


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

Thank you Allison, 

 

I appreciate if you mentioned that it is most likely due to cross filter direction. The arrows need to point to your main table in all three relationships for this to work. It was key factor and achieved desired results. 

 

 

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

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.