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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jereaallikko
Helper III
Helper III

DAX with Multiple IF Contains Statements

Hi all,

 

I am trying to figure out a simple DAX with multiple conditions:

 

If [Column] contains "This1" then "That1" elseif [Column] contains "This2" then "That2" elseif [Column] contains "This3" then "That3" else null

 

I know that this could easily be done with conditional or custom column, but for now I need to do it with DAX. Any suggestions How this could be done?

 

BR,

Jere

7 REPLIES 7
jereaallikko
Helper III
Helper III

Hi @VahidDM & @Tanushree_Kapse 

 

What I meant, is that "This1" is included in the column. For instance, if a column value is "This1is", DAX will return "That1". Similarly, if the value is "This1isnot" it will still return "That1", because the value CONTAINS "This1"

That is what I meant with CONTAINS, not equals (=).

 

Any suggestions?

@jereaallikko 

Can you share a sample of your table after removing sensitive data here?

 

Appreciate your Kudo!!

Hi @VahidDM 

 

The table looks similar to this: 

 

DAX_CONTAINS.PNGThe "Country" Column is the one that I am trying to build with DAX. So when [Name] CONTAINS "FIN", it returns "Finland". Same goes with "GER", "Germany" & "RUS", "Russia". 

@jereaallikko 

 

Try this measure :

Country =
VAR _A =
    MAX ( 'Table'[Name] )
RETURN
    IF (
        LEFT ( _A, 3 ) = "FIN",
        "Finland",
        IF (
            LEFT ( _A, 3 ) = "GER",
            "Germany",
            IF ( LEFT ( _A, 3 ) = "RUS", "Russia", BLANK () )
        )
    )

 

Output:

VahidDM_0-1631094133608.png

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos✌️!!

 

This worked well! Thanks a lot.

 

Is there a way to apply similar solution to DAX column? This works in a DAX measure but if I want to use this as a slicer, it must be as a DAX column since DAX measures cannot be used as a slicer.

VahidDM
Super User
Super User

Hi @jereaallikko 

Try this measure with IF:

Measure =
IF (
    [Column] = "This1",
    "That1",
    IF ( [Column] = "This2", "That2", IF ( [Column] = "This3", "That3", BLANK () ) )
)

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos✌️!!

 

Tanushree_Kapse
Impactful Individual
Impactful Individual

Hi @jereaallikko ,

 

Try this DAX:
Measure= IF([Column]="This1","That",IF([Column]="This2","That2",IF([Column]="This3","That3")), BLANK())

 

Mark this as a solution, if I answered your question.

Kudos are always appreciated.

 

Thanks!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.