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
LMcQ
Regular Visitor

How to extract a location name from a Description text field using a "List of Locations"

This is an example of the HistoryExtracts[Description]:
      Removed 50 from stockroom StockroomName, client Client-Name

_StockroomList would have about 25 names
this is the code I'm trying to work out....

AffectedStockroom =
VAR _SRname = FILTER('Locations', Locations[Site Category] = "E")
VAR _StockroomList = SELECTCOLUMNS(_SRname, "Stockroom", Locations[Location Name])
RETURN
    IF(HistoryExtracts[Type] = "Stockroom Update" && CONTAINSSTRING(HistoryExtracts[Description], _SRname, "Not Found")

Error message is: The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.

What am I missing?? do I have to do a switch for each Stockroom name?
Thanks for your help.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @LMcQ ,

Please update the formula of calculated column [AffectedStockroom] as below and check if it can return your expected result... Please find the details in the attachment.

AffectedStockroom = 
VAR _loc =
    CALCULATE (
        MAX ( 'Locations'[Location Name] ),
        FILTER (
            'Locations',
            IFERROR (
                SEARCH ( 'HistoryExtracts'[Description], 'Locations'[Location Name], 1, 0 ),
                0
            ) > 0
                && 'Locations'[Site Category] = "E"
        )
    )
RETURN
    IF (
        HistoryExtracts[Type] = "Stockroom Update"
            && NOT ( ISBLANK ( _loc ) ),
        _loc,
        "Not Found"
    )

vyiruanmsft_0-1682924038165.png

Best Regards

View solution in original post

2 REPLIES 2
LMcQ
Regular Visitor

Thank you so much... I've spent days trying to figure it out on my own... Fantastic!!! Sorting and filtering have always been a weak spot for me

Anonymous
Not applicable

Hi @LMcQ ,

Please update the formula of calculated column [AffectedStockroom] as below and check if it can return your expected result... Please find the details in the attachment.

AffectedStockroom = 
VAR _loc =
    CALCULATE (
        MAX ( 'Locations'[Location Name] ),
        FILTER (
            'Locations',
            IFERROR (
                SEARCH ( 'HistoryExtracts'[Description], 'Locations'[Location Name], 1, 0 ),
                0
            ) > 0
                && 'Locations'[Site Category] = "E"
        )
    )
RETURN
    IF (
        HistoryExtracts[Type] = "Stockroom Update"
            && NOT ( ISBLANK ( _loc ) ),
        _loc,
        "Not Found"
    )

vyiruanmsft_0-1682924038165.png

Best Regards

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.