Forum Discussion
Switch Column Logic Help
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()
)
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.
- Anonymous7 years agoNot applicable
Anonymous -
Again, I'm not sure I understand the requirement clearly, but AlB has a good answer. I will expand on the answer a bit by defining what I think is your EmpCount:
Label = var EmpCount = COUNTROWS(FILTER(ALL('ActiveHC'), ActiveHC[Layer 2] = EARLIER(ActiveHC[Layer 2]) && 'ActiveHC'[Country Name] in {"Turkey","Greece","Italy"})) IF ( EmpCount > 0, "Cars", SWITCH ( TRUE (), ActiveHC[Country Name] = "Turkey", "Cars", ActiveHC[Country Name] = "Greece", "Cars", ActiveHC[Country Name] = "Italy", "Cars", 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 () ) )