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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
pbiforum123
Post Patron
Post Patron

Help needed in creating calculated column and create the values based on the tag using CONTAINSTRING

@Fowmy 
I need help in creating the calculated column using CONTAINSTRING or anyother string function.

Let say there is column called "Page Name" in that I need to find the below patterns and tag it as the one given on the right side.


US:*:shop-all:* --> PLP
US:*:products:* --> PDP
US:* --> Homepage
US:search --> SRP

Remaining values tag it as "Others"...

Can you please help on this.Please let me know if you have any questions.

1 ACCEPTED SOLUTION

@pbiforum123 

Use

new column =
SWITCH (
    TRUE (),
    CONTAINSSTRING ( TableName[ColumnName], "US:*:shop-all:" ), "PLP",
    CONTAINSSTRING ( TableName[ColumnName], "US:*:products:" ), "PDP",
    CONTAINSSTRING ( TableName[ColumnName], "US:search :" ), "SRP",
    CONTAINSSTRING ( TableName[ColumnName], "US:" ), "Homepage",
    "Others"
)

View solution in original post

5 REPLIES 5
tamerj1
Community Champion
Community Champion

Hi @pbiforum123 
Please try

new column =
SWITCH (
    TRUE (),
    CONTAINSSTRING ( TableName[ColumnName], "US:*:shop-all:" ), "PLP",
    CONTAINSSTRING ( TableName[ColumnName], "US:*:products:" ), "PDP",
    CONTAINSSTRING ( TableName[ColumnName], "US:search :" ), "SRP",
    CONTAINSSTRING ( TableName[ColumnName], "US:" ), "Homepage"
)

@tamerj1 Everything looks good except the "Others" part. Could you please help on this.

@pbiforum123 

Use

new column =
SWITCH (
    TRUE (),
    CONTAINSSTRING ( TableName[ColumnName], "US:*:shop-all:" ), "PLP",
    CONTAINSSTRING ( TableName[ColumnName], "US:*:products:" ), "PDP",
    CONTAINSSTRING ( TableName[ColumnName], "US:search :" ), "SRP",
    CONTAINSSTRING ( TableName[ColumnName], "US:" ), "Homepage",
    "Others"
)
amitchandak
Super User
Super User

@pbiforum123 , You can try the search, there you can use wildcard characters

https://docs.microsoft.com/en-us/dax/search-function-dax

 

Example 

new column  =Switch( True() ,

Search("US:*:shop-all:", [Column],,0) >0 ,  "PLP",

Search("US:*:products:", [Column],,0) >0 ,  "PDP",

Search("US:search :", [Column],,0) , "SRP",

Search("US:", [Column],,0) , "Homepage"

)

 

Order is important.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak Thanks but when I am trying to use the code that you have shared I am getting below error

 

Function 'SWITCH' does not support comparing values of type True/False with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.