Forum Discussion
Create new Column Using Conditions from multiple other columns
- 1 year ago
Hi Swiftojo , a calculated column would be a good option here. The DAX SWITCH function would be a perfect candidate for your use case. How a SWITCH function works is it evaluates multiple conditions and returns a value based on the condition met. This is similar to using nested IF statements, however it can reduce query complexity and make it much more readible.
Here is an example DAX for your use case:Column = SWITCH( TRUE(), CONTAINSSTRING('TableName'[Column A], "Info A"), "Info A", CONTAINSSTRING('TableName'[Column A], "Info B"), "Info B", 'TableName'[Column B] = "Type 1", "Info", 'TableName'[Column C] = "Type 1" && 'TableName'[Column B] <> "Type 1", "Info", BLANK() )If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.
Thanks,Samson
Hi Swiftojo , a calculated column would be a good option here. The DAX SWITCH function would be a perfect candidate for your use case. How a SWITCH function works is it evaluates multiple conditions and returns a value based on the condition met. This is similar to using nested IF statements, however it can reduce query complexity and make it much more readible.
Here is an example DAX for your use case:
Column =
SWITCH(
TRUE(),
CONTAINSSTRING('TableName'[Column A], "Info A"), "Info A",
CONTAINSSTRING('TableName'[Column A], "Info B"), "Info B",
'TableName'[Column B] = "Type 1", "Info",
'TableName'[Column C] = "Type 1" && 'TableName'[Column B] <> "Type 1", "Info",
BLANK()
)
If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.
Thanks,
Samson