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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Kumshan450
Helper III
Helper III

IF functions to find text within a string

I want to find text within a string, want to return two values. 

 

ASSET_DESCProduct
PASSENGER CARRIERCV =If a text contains "Carr" then CV otherwise MC
PLATINAMC
PULSARMC

 

I entered the below formula but it's not working. 

 

Product = if(iserror(search("CAR",'Allocation dump required MP state'[ASSET_DESC])),"CV","MC")

 

Also, I wanted to add a column based on three column values. 

 

PRODUCTLIVE_EXPBOM BUCKETCLASSIFICATION
MC/CVEXPirrespective of bucketNPA
MC/CVLIV6+NPA
MC  LIVo or 10 to 1 bucket
MCLIV2  or 3 or 4 or 5 or 62 to 6 bucket
CVLIV0X bucket
CVLIV1 or 2  or 3 or 4 or 5 or 61 to 6 bucket

 

 

1 ACCEPTED SOLUTION
MariaP
Solution Supplier
Solution Supplier

Hi Kumshan450

Based on your data I created 2 tables and added the following 2 columns:

 

Create a column for asset type:

Asset_Type = 

    var myResult = IFERROR(SEARCH("CAR",[ASSET_DESC]),-1)

    RETURN

     IF (myResult = -1,  "MC", "CV")  

Create this if statement for your other bins:

 

Classification2 = IF

    ( 'PRODUCT'[Product] = "MC/CV" && 'PRODUCT'[Live_Exp] = "EXP", "NPA",

    IF ('PRODUCT'[Product] = "MC/CV" && 'PRODUCT'[Live_Exp] = "LIV", "NPA",

        IF ('PRODUCT'[Product] = "MC" && 'PRODUCT'[Live_Exp] = "LIV" && 'PRODUCT'[Bom_Bucket_Real] IN {0,1}   , "0 to 1 bucket",  

        IF ('PRODUCT'[Product] = "MC" && 'PRODUCT'[Live_Exp] = "LIV" && 'PRODUCT'[Bom_Bucket_Real] IN {2,3,4,5,6}   , "2 to 6 bucket",   

        IF ('PRODUCT'[Product] = "CV" && 'PRODUCT'[Live_Exp] = "LIV" && 'PRODUCT'[Bom_Bucket_Real] IN {1,2,3,4,5,6}   , "1 to 6 bucket",

        IF ('PRODUCT'[Product] = "CV" && 'PRODUCT'[Live_Exp] = "LIV" && 'PRODUCT'[Bom_Bucket_Real] = 0    , "X bucket",

        IF ('PRODUCT'[Product] = "CV" && 'PRODUCT'[Live_Exp] = "LIV" && 'PRODUCT'[Bom_Bucket_Real] IN {1,2,3,4,5,6}  , "1 to 6 bucket",

     BLANK() ) ) )))))

Results:

ProductResults.PNG

 

POWER BI FILE INCASE NEEDED:

SampleFile

 

Hope this is interpreted as you require.

 

View solution in original post

1 REPLY 1
MariaP
Solution Supplier
Solution Supplier

Hi Kumshan450

Based on your data I created 2 tables and added the following 2 columns:

 

Create a column for asset type:

Asset_Type = 

    var myResult = IFERROR(SEARCH("CAR",[ASSET_DESC]),-1)

    RETURN

     IF (myResult = -1,  "MC", "CV")  

Create this if statement for your other bins:

 

Classification2 = IF

    ( 'PRODUCT'[Product] = "MC/CV" && 'PRODUCT'[Live_Exp] = "EXP", "NPA",

    IF ('PRODUCT'[Product] = "MC/CV" && 'PRODUCT'[Live_Exp] = "LIV", "NPA",

        IF ('PRODUCT'[Product] = "MC" && 'PRODUCT'[Live_Exp] = "LIV" && 'PRODUCT'[Bom_Bucket_Real] IN {0,1}   , "0 to 1 bucket",  

        IF ('PRODUCT'[Product] = "MC" && 'PRODUCT'[Live_Exp] = "LIV" && 'PRODUCT'[Bom_Bucket_Real] IN {2,3,4,5,6}   , "2 to 6 bucket",   

        IF ('PRODUCT'[Product] = "CV" && 'PRODUCT'[Live_Exp] = "LIV" && 'PRODUCT'[Bom_Bucket_Real] IN {1,2,3,4,5,6}   , "1 to 6 bucket",

        IF ('PRODUCT'[Product] = "CV" && 'PRODUCT'[Live_Exp] = "LIV" && 'PRODUCT'[Bom_Bucket_Real] = 0    , "X bucket",

        IF ('PRODUCT'[Product] = "CV" && 'PRODUCT'[Live_Exp] = "LIV" && 'PRODUCT'[Bom_Bucket_Real] IN {1,2,3,4,5,6}  , "1 to 6 bucket",

     BLANK() ) ) )))))

Results:

ProductResults.PNG

 

POWER BI FILE INCASE NEEDED:

SampleFile

 

Hope this is interpreted as you require.

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.