Forum Discussion
If statement more than one table
- 5 years ago
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 regardsDenisBlog: WhatTheFact.biFollow me: twitter.com/DenSelimovic
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.
- powerbihelp875 years ago
Helper V
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" ))
- selimovd5 years ago
Most Valuable Professional
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 regardsDenisBlog: WhatTheFact.biFollow me: twitter.com/DenSelimovic- powerbihelp875 years ago
Helper V
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