Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

How to switch values for a variable with text containing ""

I am trying to create a new column in which I group values from another variable.

One of the values (Old 6 below) from the other column contains "", and the DAX-function is not accepting this, when I am trying to switch values.

 

Can anyone help me with this?

Here is an example of my DAX for the new variable:

 

New variable = SWITCH([Old variable],
"Old 1", "New 1",
"Old 2", "New 1",
"Old 3", "New 1",
"Old 4", "New 2",
"Old 5", "New 2",
"Old "6"", "New 3",
"Other")
  • Anonymous , Try this:

    New Column = SWITCH(TableName[Old],
    "Old 1","New 1",
    "Old 2", "New 1",
    "Old 3","New 1",
    "Old 4", "New 2",
    "Old 5","New 2",
    "Old 6", "New 3",
    "Old ""6""", "New 3",
    "Other")
     

2 Replies

  • Anonymous , Try this:

    New Column = SWITCH(TableName[Old],
    "Old 1","New 1",
    "Old 2", "New 1",
    "Old 3","New 1",
    "Old 4", "New 2",
    "Old 5","New 2",
    "Old 6", "New 3",
    "Old ""6""", "New 3",
    "Other")
     
    • Anonymous's avatar
      Anonymous
      Not applicable

      Works perfectly!

       

      Thank you!