Forum Discussion

Mauri_Castro_70's avatar
2 years ago
Solved

Help with Swith() True() Calculated Column with multiple Criterias

Hello Guys,

 

I am traying to map some values/offerings to specific users using Switch/true with multiple criterias such as:

 

User_name =

SWITCH (
TRUE (),

CONTAINSSTRING ('Offering'[Offering],
"Mobility"
)
|| CONTAINSSTRING ( [Offering], "Security" )
&& NOT CONTAINSSTRING ( [Approver], "L2" )
&& NOT CONTAINSSTRING ( [Region], "WW" )
&& NOT CONTAINSSTRING ( [Region], "Asia" ) && NOT CONTAINSSTRING ( [Region], "ANZ" ), "Mike",

John

 

However, I keep getting values with "WW" in the Region Column for "Mike". Below is a sample of the table.

 

Thanks in advance for the help!

 

Base table could look like this:

ApproverRegionOffering
L2 Deliver_WWAsiaMobility-Site Support
L4 Deliver_WWWWMobility-Site Support
L4 Deliver_WWANZMobility-Site Support
L2 Deliver_WWAmericasSecurity-Site Support
L4 Deliver_WWUKSecurity-Site Support
L4 Deliver_WWNorth CentralSecurity-Site Support
  • Mauri_Castro_70 ,

    Please try the following modification:

    User_name = SWITCH (
                    TRUE (),
                   OR( CONTAINSSTRING ('Offering'[Offering], "Mobility"), CONTAINSSTRING ( [Offering], "Security" ))
    && NOT( CONTAINSSTRING ( [Approver], "L2" ))
    && NOT (CONTAINSSTRING ( [Region], "WW" ))
    && NOT (CONTAINSSTRING ( [Region], "Asia" )) && NOT (CONTAINSSTRING ( [Region], "ANZ" )), "Mike",
    "John" )

    Not sure if this is the final result you are looking for:

    Hope this works.

    Regards,

     

  • rsbin's avatar
    rsbin
    2 years ago

    Mauri_Castro_70 ,

    Glad to hear it worked for you.  As for adding a third argument, simply "nest" them as you would an IF statement in Excel.
    OR( Condition 3, OR ( Condition 1, Condition 2) ).

    Best Regards,

5 Replies

  • rsbin's avatar
    rsbin
    Community Champion

    Mauri_Castro_70 ,

    Please try the following modification:

    User_name = SWITCH (
                    TRUE (),
                   OR( CONTAINSSTRING ('Offering'[Offering], "Mobility"), CONTAINSSTRING ( [Offering], "Security" ))
    && NOT( CONTAINSSTRING ( [Approver], "L2" ))
    && NOT (CONTAINSSTRING ( [Region], "WW" ))
    && NOT (CONTAINSSTRING ( [Region], "Asia" )) && NOT (CONTAINSSTRING ( [Region], "ANZ" )), "Mike",
    "John" )

    Not sure if this is the final result you are looking for:

    Hope this works.

    Regards,

     

    • OMG!!! It worked perfectly! Thanks so much!!!

       

      You Rock!

       

      Mauri Castro

      • Mauri_Castro_70's avatar
        Mauri_Castro_70
        Helper I

        Sorry, One more quick question. I see that the OR operator only allows for 2 Logical arguments... how can I include a 3rd argument? Should I enter a whole new string for the same User_Name?

         

        Thanks again!

        Mauricio