Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Fahid
Helper I
Helper I

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 efficient in this case. I have tried to solve this with DAX Substitute condition but doesn’t work properly because of too many text substitutions.

 

Is there a way to keep 4 values same and redirect 385 text values to “Others”?

 

Thanks a lot for your help.

 

BR,

Fahid

3 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

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". 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

AlB
Community Champion
Community Champion

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

 

View solution in original post

AlB
Community Champion
Community Champion

@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" 

View solution in original post

6 REPLIES 6
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @Fahid

 

You may refer to below calculated column.List the 4 values in {...} with IN function.

Column =
IF ( Table4[Text] IN { "a", "c", "d", "g" }, "Single", "Others" )

1.png

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks to everyone for your reply.

@AlB your below solution works perfect and marked it as solution.

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

 

@v-cherch-msft, unfortunately, I couldn’t run your solution.

 

@Greg_Deckler your solution works fine but it can’t replace Blanks to “Others”. I am marking it also as a solution.

 

BR,

Fahid

AlB
Community Champion
Community Champion

@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" 

Hey @AlB,

 

Sorry for late reply and again sorry for making silly mistake. I apologize. You are correct, and code works fine in this case. I marked it also as a solution. Thanks again for helping me out.

 

BR,

Fahid

AlB
Community Champion
Community Champion

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

 

Greg_Deckler
Community Champion
Community Champion

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". 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.