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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
powerbihelp87
Helper IV
Helper IV

If statement more than one table

I need help with multiple table If statement, I tried to give sample tables below. 

If Column Code=100 then the new column should be XYZ else if the Column is Grp is 8fni then it should be ABC, the rest are EFG

 

Table 1:

CodeSalesDAX HELP!
100190 
10293 
10989 
20093 
2909 
10039 
10089 
20099 
10020 
290289 
10298 
10978 
200398 
10292 
10083 
109109 

 

Table 2:

keyGrp
a0so
b0dk0
c0kis
d8vhi
e8fni
f8hf8
1 ACCEPTED SOLUTION

Hey @powerbihelp87 ,

 

yes, you can write it like that:

DAX Help Column =
SWITCH(
    TRUE(),
    'Table 1'[Code] = "100", "XYZ",
    RELATED( 'Table 2'[Grp] )
        IN {
        "8fni",
        "8vhi",
        "0kis"
    }, "ABC",
    "EFG"
)

 

By the way, always link someone in an answer like that: @powerbihelp87 

Otherwise I won't get a notification that you answered.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

 

View solution in original post

6 REPLIES 6
selimovd
Super User
Super User

Hey @powerbihelp87 ,

 

logically it doesn't really make sense.

A calculated column always has to be in a specific table.

 

You are asking to put "XYZ" when a column from Table 1 has a value and "ABC" when the column of another table is a specific value. How are they connected?

Please explain a little better.

 

Best regards

Denis

parry2k
Super User
Super User

@powerbihelp87 not really clear what you are looking for? How these tables are connected? What is your expected output give the logic you explained. The most critical part is how these tables are connected.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@selimovd  @parry2k I was missing the Code column in the example Table 2 to show they are related, I was able to figure out the formula I needed below. It works fine.  I am trying to see how to write multiple options if the IF Related portion of the formula.

      

 DAX Help Column  =IF(Table 1[Code]="100", "XYZ",IF(RELATED(Table 2[Grp]="8fni","ABC","EFG" ))

Hey @powerbihelp87 ,

 

sure, next time just give more details.

You can make it more readable with a SWITCH/TRUE:

DAX Help Column =
SWITCH(
    TRUE(),
    'Table 1'[Code] = "100", "XYZ",
    RELATED( 'Table 2'[Grp] ) = "8fni", "ABC",
    "EFG"
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

@selimovd 

Thanks Denis! 

 

Do you know how I can write the syntax if there are multiple options for this portion:

 RELATED( 'Table 2'[Grp] ) = "8fni"

For example if any of these from Grp field: "8fni" or "8vhi" or "0kis"  THEN it is ABC

Hey @powerbihelp87 ,

 

yes, you can write it like that:

DAX Help Column =
SWITCH(
    TRUE(),
    'Table 1'[Code] = "100", "XYZ",
    RELATED( 'Table 2'[Grp] )
        IN {
        "8fni",
        "8vhi",
        "0kis"
    }, "ABC",
    "EFG"
)

 

By the way, always link someone in an answer like that: @powerbihelp87 

Otherwise I won't get a notification that you answered.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors