Forum Discussion
Switch Column Logic Help
Anonymous
I'm trying to write logic like this to get the above return, but not having luck:
Label = VAR _Country = SWITCH( TRUE (), ActiveHC[Country Name] = "Turkey", "Cars", ActiveHC[Country Name] = "Greece", "Cars", ActiveHC[Country Name] = "Italy", "Cars", Blank() ) VAR _Segment = SWITCH( True(), ActiveHC[Layer 2] = "Beth", "Corporate", ActiveHC[Layer 2] = "Joanie", "Corporate", ActiveHC[Layer 2] = "Dan", "Corporate", ActiveHC[Layer 2] = "Bill", "Corporate", ActiveHC[Layer 2] = "Christina", "Corporate", ActiveHC[Layer 2] = "Steven", "Cars", ActiveHC[Layer 2] = "Bobby", "Audio", ActiveHC[Layer 2] = "Matt", "Photos", ActiveHC[Layer 2] = "Peter", "Photos", ActiveHC[Layer 2] = "Edward", "Photos", ActiveHC[Layer 2] = "Joey", "Software", ActiveHC[Business Unit] = "Cameras", "Cameras", BLANK () ) ) RETURN IF _COUNTRY
Essentially, If Country is equal to one of those 3 countries I want it to be called "CARS" -- I want that to default regardless of the additional criteria I have below. However, if the country does NOT equal those 3, I want it to return the other values I have broken out.
I just can't get the RETURN IF COUNTRY thing right using the 2 VAR pieces.
Anonymous - Does this work?:
Label =
SWITCH(
TRUE(),
ActiveHC[Country Name] IN { "Turkey", "Greece", "Italy" }, "Cars",
ActiveHC[Layer 2] IN { "Beth", "Joanie", "Dan", "Bill", "Christina" }, "Corporate",
ActiveHC[Layer 2] = "Steven", "Cars",
ActiveHC[Layer 2] = "Bobby", "Audio",
ActiveHC[Layer 2] = IN { "Matt", "Peter", "Edward" }, "Photos",
ActiveHC[Layer 2] = "Joey", "Software",
ActiveHC[Business Unit] = "Cameras", "Cameras",
BLANK()
)
- Anonymous7 years agoNot applicable
Thanks for this, but it will not work. That's a standard SWITCH which I can do, I'm trying to make it so the COUNTRY is the default return if it is NOT one of those countries, then return the other switch function.
- Anonymous7 years agoNot applicable
Anonymous -
Switch will look for the first true statement and return the associated value. In this example, the first check is the country, so if that country is found, it will return Cars.
This won't work if you the label is dependent on rows other than the current row. If you want to check conditions in other rows, we'll need to understand the requirement more precisely.
Hope this helps,
Nathan
- Anonymous7 years agoNot applicable
Anonymous Hi Nate,
All my requirements are stated in the post. Greg_Deckler and AlB suggested I add more context which I did. I believe everything is there that is needed. I don't know how else to explain it.
The short end of the stick is, If the country equals those 3 countries then I need it to default to CARS, otherwise, I need the other labels represented. The problem is that some of those managers also have people in those countries, but I want the CARS label to be overwritten. That's why I included a BLANK value piece in my switch to help it along.