Forum Discussion
CMoppet
2 years agoHelper IV
Conditional Column if value appears within a list
Hello, I have a conditional column in a table called 'WO DATA' with various clauses based on the values in a column called 'Account NAME'. It's straightforward because I can reply on the accou...
- 2 years ago
Try the following :
Column = IF( [SAP Account Id] IN {5300023122, 5300023123, 5300023124, 5300023125, 5300023126, 5300023127, 5300023129, 5300023130, 5300023132, 5300023131}, "EMCOR", IF( CONTAINSSTRING([Account Name], "Waitrose"), "Waitrose", IF( CONTAINSSTRING([Account Name], "John Lewis"), "John Lewis", IF( CONTAINSSTRING([Account Name], "Thames Water"), "Thames Water", IF( CONTAINSSTRING([Account Name], "WSP"), "WSP", BLANK() ) ) ) ) )
AmiraBedh
2 years agoSuper User
AZTEC Column =
IF(
'WO DATA'[Account NUMBER] IN {5300023122, 5300023123, 5300023124, 5300023125, 5300023126, 5300023127, 5300023129, 5300023130, 5300023132, 5300023131},
"AZTEC",
// Replace this with your existing conditions or default value
)CMoppet
2 years agoHelper IV
Ah, I see. So I need to combine whatI already had in the conditional column, with what you've provided above? I've tried this:
Column =
IF([SAP Account Id] IN {5300023122, 5300023123, 5300023124, 5300023125, 5300023126, 5300023127, 5300023129, 5300023130, 5300023132, 5300023131},
"EMCOR"), //
else if Text.Contains([Account Name], "Waitrose") then "Waitrose" else if Text.Contains([Account Name], "John Lewis") then "John Lewis" else if Text.Contains([Account Name], "Thames Water") then "Thames Water" else if Text.Contains([Account Name], "WSP") then "WSP" else null)
But it's throwing up a syntax error. Please can you help me spot the issue? I'm very grateful for your help. I'm not very good at writing DAX yet, but am learning...
- AmiraBedh2 years agoSuper User
Try the following :
Column = IF( [SAP Account Id] IN {5300023122, 5300023123, 5300023124, 5300023125, 5300023126, 5300023127, 5300023129, 5300023130, 5300023132, 5300023131}, "EMCOR", IF( CONTAINSSTRING([Account Name], "Waitrose"), "Waitrose", IF( CONTAINSSTRING([Account Name], "John Lewis"), "John Lewis", IF( CONTAINSSTRING([Account Name], "Thames Water"), "Thames Water", IF( CONTAINSSTRING([Account Name], "WSP"), "WSP", BLANK() ) ) ) ) )