cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
DAMO16466464644 Regular Visitor
Regular Visitor

Multiple if statements to check text critea in a colum then display my text

Hi,

 

Am pretty new to DAX and am really struggling with creating this formula,

 

What I need to achieve is I need to check multiple codes in a Colum and if they match the criteria then it would display the text that I need. But then if they don’t match if would check the next lot of codes. So it’s like IF OR statement in excel.

I Have a COLUM that looks like this which is called SDCC,

 

SDCC

ONL

MIP

ABZ

MXX

TDX

REK

CVG

AKL

GTW

AMM

ALG

 

In more details i would need create a measure that would match ONL, MIP, ABZ MXX then display the text that I would need but if it does not match, then go onto the next check of codes AKL, GTW, AMM, ALG then display my text.

 

below is the code that I used between two tables but I could only check one value  “REK” this is what I am struggling with…. I am not sure how to check multiple references. I bet it’s something very simple and am overthinking it maybe.

 

CONTAINS3 = IF(CONTAINS(RELATEDTABLE(Sheet1), test[CODE], "REK"),

   "CVG",

   ""

)

 

I also tried creating a new custum colum by using this

 

if [SDCC] = "ATH" and [SDCC] = "BAH" and [SDCC] = "BAK" and [SDCC] = "BEG" and [SDCC] = "BLR"
then "CVG"
else if [SDCC] = "BRU" and [SDCC] ="CAI" and [SDCC] ="DHA" and [SDCC] = "JNB"
then "LEJ"
else "Range Unknown"

Thanks in advance for the help!

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Multiple if statements to check text critea in a colum then display my text

Hi @DAMO16466464644 

 

You may try to use IN Function.For example:

 

Column =
IF (
    Table1[SDCC] IN { "ATH", "BAH", "BAK", "BLR" },
    "CVG",
    IF ( Table1[SDCC] IN { "BRU", "CAI", "DHA", "JNB" }, "LEJ", "Range Unknown" )
)

Regards,

Cherie

 

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 REPLIES 3
Super User
Super User

Re: Multiple if statements to check text critea in a colum then display my text

So, you can use "||" for OR criteria (&& for AND). But, I would use a SWITCH, not nested IF statements.


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!


DAMO16466464644 Regular Visitor
Regular Visitor

Re: Multiple if statements to check text critea in a colum then display my text

Do you have any examples for using SWITCH? and thank you for your response.

Community Support Team
Community Support Team

Re: Multiple if statements to check text critea in a colum then display my text

Hi @DAMO16466464644 

 

You may try to use IN Function.For example:

 

Column =
IF (
    Table1[SDCC] IN { "ATH", "BAH", "BAK", "BLR" },
    "CVG",
    IF ( Table1[SDCC] IN { "BRU", "CAI", "DHA", "JNB" }, "LEJ", "Range Unknown" )
)

Regards,

Cherie

 

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.