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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Strongbuck
Helper I
Helper I

Can I use two values for FIND? I need to exclude records that contain W.O. when they contain 22-

Can I use two values in the FIND command?  The data looks like:
 
Table name is Work_Orders.
 
Title                                                 Max_No
W.O. 682426 Building C6211                2
W.O. 680021 Dining Hall A7006           2
W.O. #22-706828 - Bldg 231                1
W.O. 671049 Aliya Kanji B223               2
22-708234 FU 405                                 1
 
I am trying to populate the Max_WO_Data column with the following data based on the Max_No field.
Title                                                    Max_WO_Data
W.O. 682426 Building C6211                22-682426
680021 Dining Hall B8006                   22-680021
W.O. #22-706828 - Bldg 231                22-706828
W.O. 671049 Aliya Kanji B223               22-671049
22-708234 RM 505                               22-708234
 
 This is what I came up with but it doesn't work for records that have both W.O and 22-.  I also need the code to concatenate the 22- when it isn't included.
 
Max_WO_Data =
VAR _loc =
    FIND ( "22-", 'Work_Orders'[title], 1 , BLANK() )

 

VAR _locWO =
    FIND ( "W.O. ", 'Work_Orders'[title], 1 , BLANK() )

 

VAR _maxID =
    IF (
        _loc <> BLANK(),
        ( MID ( 'Work_Orders'[title], _loc, 10 ) )
    )

 

VAR _maxIDWO =
    IF (
        _locWO <> BLANK(),
        ( MID ( 'Work_Orders'[title], _locWO + 4, 8 ) )
    )

 

RETURN
IF(SELECTEDVALUE('Work_Orders'[Max_Type]) = "1", _maxID, _maxIDWO)
 
I'm learning DAX but I'm stumbling over the syntax of some of the functions.  Any help would be appreciated!
4 REPLIES 4
v-yetao1-msft
Community Support
Community Support

Hi @Strongbuck 

Did you fix your problem ? If it has been solved, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,
Community Support Team _ Ailsa Tao

wdx223_Daniel
Super User
Super User

Max_WO_Data =VAR _a=IF(FIND("22-",'Work_Orders'[title],,0)>0,1,0) RETURN IF(_a,"22-","")&MID('Work_Orders'[title],MAXX({"W.O. ","W.O. #"},FIND([Value],'Work_Orders'[title],,0))+1,6+_a*3)

just for the sample data

I ran what you wrote and the data wasn't parsed properly which is my original problem.  What I am going to try next is to generate 1 or 2 depending on what the title contains 1 = 22- and 2 = W.O.

 

What I am seeing when I add this column is that the data is being separated properly.  Now, I just need to alter the code to query the table with 1 or 2 and base the length logic on that.  Wish me luck!

Thanks!  I'll see if it parses the data like I need it to.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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