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
Anonymous
Not applicable

Replacing multiple text values

Hi, 

 

I'm looking to create a column that will display new text values. Below is the formula I've been using so far, but looking for something that would work using CONTAINS not EQUAL as there are over 2,000 distinct values. So, for example, if the text contains organic then return "Organic" if paid return "Paid". 

 

Column = IF('External Traffic'[Source Medium] = "google / organic", "Organic",
if('External Traffic'[Source Medium] = "Facebook / Paid", "Paid",
"Other"))
 
I've found other solutions on this forum but it seems to be applying only to numerical values. Any help is much appreciated!
1 ACCEPTED SOLUTION
gingerbread
Frequent Visitor

You can use the DAX function SWITCH along with the CONTAINS function to check if the text field contains certain values and return different text based on the result.

Here is an example of how you can modify your formula to achieve this:

 

Column = SWITCH(
TRUE(),
CONTAINS('External Traffic'[Source Medium], "google / organic"), "Organic",
CONTAINS('External Traffic'[Source Medium], "Facebook / Paid"), "Paid",
"Other"
)

This formula will check if the Source Medium field contains the string "google / organic" and return "Organic" if it does, then it will check if it contains the string "Facebook / Paid" and return "Paid" if it does, and finally it will return "Other" if none of the previous conditions are met.

View solution in original post

3 REPLIES 3
gingerbread
Frequent Visitor

You can use the DAX function SWITCH along with the CONTAINS function to check if the text field contains certain values and return different text based on the result.

Here is an example of how you can modify your formula to achieve this:

 

Column = SWITCH(
TRUE(),
CONTAINS('External Traffic'[Source Medium], "google / organic"), "Organic",
CONTAINS('External Traffic'[Source Medium], "Facebook / Paid"), "Paid",
"Other"
)

This formula will check if the Source Medium field contains the string "google / organic" and return "Organic" if it does, then it will check if it contains the string "Facebook / Paid" and return "Paid" if it does, and finally it will return "Other" if none of the previous conditions are met.

Barthel
Solution Sage
Solution Sage

Hey @Anonymous,

You can use the SWITCH function to more easily handle multiple IF conditions at once. For the contains condition, use the CONTAINSSTRING function. For instance:

Column =
SWITCH (
    TRUE,
    CONTAINSSTRING ( 'External Traffic'[Source Medium], "google / organic" ), "Organic",
    CONTAINSSTRING ( 'External Traffic'[Source Medium], "Facebook / Paid" ), "Paid",
    "Other"
)

 

Nathaniel_C
Community Champion
Community Champion

Hi @Anonymous ,

Try using CONTAINS() or CONTAINSSTRING().

Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.