Forum Discussion

Fahid's avatar
Fahid
Helper I
7 years ago
Solved

Changing multiple text values to a single text value

Hello everyone. I have 389 different text values in a column. I want to keep 4 values same and change rest 385 text values to “Others”.   Using Replace or Conditional Column in query editor is not ...
  • Greg_Deckler's avatar
    7 years ago

    I would look at creating a Group in DAX. You could create a group for each of your 4 values and then include an "Other" group. I think this would be the quickest and most efficient way of doing what you are looking to do. In your fields area, click the ellipses (...) and choose "New group". 

  • AlB's avatar
    7 years ago

    Hi Fahid

     

    You can add a custom column in the query editor with the following code:

     

    = if List.Contains({Val1,Val2, Val3, Val4},[YourCurrentColumn]) 
    then [YourCurrentColumn]
    else "Other"

    where Val1-4 are the values you want to keep

     

    Then, if necessary, you can remove the original column and rename the new one

     

  • AlB's avatar
    AlB
    7 years ago

    Fahid

     

    It doesn't turn all rows to others. Like I said, Val1,...Val4 are just examples and you have to substitute them for the values you want to keep (you haven't said what those values are). You cannot use "Val1"... "Val4"