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
Strongbuck
Helper I
Helper I

How do I parse the data in a field and then create a new column using only part of the field

I need to parse the data in a title field to create a column I can use to join it with another data source.  My data looks like this:

 

Issue ID     Issue Description

1234          W.O. 22-929292 needs to be addressed.

1235          22-092828 is top priority

1236          Facilities entered 22-872622 

 

I need my output to be:

 

Issue ID     Issue Description                                               Work Order No

1234          W.O. 22-929292 needs to be addressed.           22-929292

1235          22-092828 is top priority                                   22-092828

1236          Facilities entered 22-872622                              22-872622 

 

I'm new to DAX.  I see where I select the Add New Column in Power BI Desktop.  That part I understand. 

 

I searched for this issue but most of the examples are not where the text is in a variable position in the field.  I tried a few things like FIND, SEARCH and MID.  I just kept getting EOF error messages.

 

Boy do I miss my SQL "Like" command in this application.

1 ACCEPTED SOLUTION
Strongbuck
Helper I
Helper I

I came up with the following that seems to work.  It creates a column named Workorder_ID and populates it with the characters after the characters W.O. 
 
Workorder_ID =
VAR _loc = FIND ( "W.O.", 'issues_issues'[title], 1 , Blank() )  
VAR _maxID =
    IF (
        _loc <> BLANK(),
        ( MID ( 'issues_issues'[title], _loc + 5, 9 ) )
    )
RETURN
    _maxID

View solution in original post

4 REPLIES 4
Strongbuck
Helper I
Helper I

I came up with the following that seems to work.  It creates a column named Workorder_ID and populates it with the characters after the characters W.O. 
 
Workorder_ID =
VAR _loc = FIND ( "W.O.", 'issues_issues'[title], 1 , Blank() )  
VAR _maxID =
    IF (
        _loc <> BLANK(),
        ( MID ( 'issues_issues'[title], _loc + 5, 9 ) )
    )
RETURN
    _maxID
Strongbuck
Helper I
Helper I

Hi Greg,  Thanks for the code!  I'll let you know if I hit any roadblocks.

Greg_Deckler
Community Champion
Community Champion

@Strongbuck Well, maybe this, PBIX is attached below signature.

Work Order ID = 
    VAR __Dash = SEARCH("-",[Item Description],,0)
    VAR __Space = SEARCH(" ",[Item Description],__Dash,0)
    VAR __Chars = IF(__Space <> 0, __Space - __Dash, LEN([Item Description]) - __Dash + 1)
RETURN
    MID([Item Description], __Dash - 2, __Chars + 2)

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

I copied your code into Power BI and ran it.  The Work Order ID column was created but it is filled with "#Error".  The following error message is being displayed.

 

An argument of function 'SEARCH' has the wrong data type or has an invalid value.

 

I opened the pbix field you sent and see that it works beautifully in that file.  Of course, the data only included records that contained the pattern the query is lookin for.   How do you fix it so it handles data without the pattern.

 

I tried IFERROR to fix it but that gave me another error message. 

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.