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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
aldirb
New Member

text parsing mixed with a lookup value

I currently have a colum with very long descriptions that I would like to parse by searching for specific text, then return the category it belongs in.

 

TABLE A:

Line Description
po invoice id 21934i148 taxes on added funds

refrigeration coolant repairs

new refrigerator installation PO

 

TABLE B:

searchforreturnvalue
refrigRefrigeration
taxTaxes

 

Obviously i have many more categories, but would only like the return value to be ONE individual category (i.e. if a description were "Refrigerator taxes" i would want the first value to be returned, so in this case "Refrigeration").

 

Is there a way to do this by referencing a table such as Table B?

 

Currently my formula is very long and manual to update and looks like this:

Parse =
IF(
SEARCH("refrig",'2020 GLAP'[Line Description],,0) > 0, "Refrigeration",
IF(SEARCH("plumb",'2020 GLAP'[Line Description],,0) > 0, "Plumbing", "OTHER"))
 
However, in the SEARCH formula, i can't reference a separate table otherwise it errors. Does anyone have any tips on this?
1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @aldirb ,

You can create one measure as below:

text parsing.JPG

ReturnNValue =
CALCULATE (
    MAX ( 'Search'[returnvalue] ),
    FILTER (
        'Search',
        FIND ( 'Search'[searchfor], MAX ( '2020 GLAP'[Line Description] ), 1, 0 ) > 0
    )
)

Best Regards

Rena

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

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @aldirb ,

You can create one measure as below:

text parsing.JPG

ReturnNValue =
CALCULATE (
    MAX ( 'Search'[returnvalue] ),
    FILTER (
        'Search',
        FIND ( 'Search'[searchfor], MAX ( '2020 GLAP'[Line Description] ), 1, 0 ) > 0
    )
)

Best Regards

Rena

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

Try a new column in table 1

 

New column in Table 1 = minx(filter(table2,search(Table2[searchfor],Table1[Line Description],1,0)>0),Table2[returnvalue])

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Datanaut Connect on Linkedin

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors