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
Anonymous
Not applicable

SplitText by variable number of backslashes DAX Measure

Hi All,

 

Need help with my DAX. I need to be able to extract just the "Sprint ##" part from my text field

 

My text field format can be like any of the below examples

 

Team_Name\Project Name\Queue Name\Sprint 1
Team_Name\Project Name\Sprint 10
Team_Name\Queue Name\Sprint 35
Team_Name\Sprint 54

 

As you can see the number of backslashes changes, so I created the below code to turn the right most backslash into an "@", so that then I could use MID and FIND to identify and split the "Sprint ##" part out

 

IP_Sprint =

SUBSTITUTE(SELECTEDVALUE('View for PBI Report'[Iteration Path]),"\","@",
        LEN(SELECTEDVALUE('View for PBI Report'[Iteration Path]))
        -LEN(SUBSTITUTE(SELECTEDVALUE('View for PBI Report'[Iteration Path]),"\","")))

 

The above code works but I get the below error when I try to do MID(IP_Sprint,FIND("@",IP_Sprint,1)+1,10)

 

Can anyone please help me resolve the issue

 

Capture.PNG

1 ACCEPTED SOLUTION
AnkitBI
Solution Sage
Solution Sage

Hi  @Anonymous  It seems some kind of Bug in system. Find function is working fine if we are giving optional 4th parameter for "NotFoundValue" value. Please try below. Change "-1" as per you deem fit.

https://docs.microsoft.com/en-us/dax/find-function-dax

 MID([IP_Sprint],FIND("@",[IP_Sprint],1,-1)+1,10) 

 

Thanks
Ankit Jain
Do Mark it as solution if the response resolved your problem. Do Kudo the response if it seems good and helpful.

 

 

 

 

@Anonymous

View solution in original post

4 REPLIES 4
AnkitBI
Solution Sage
Solution Sage

Hi  @Anonymous  It seems some kind of Bug in system. Find function is working fine if we are giving optional 4th parameter for "NotFoundValue" value. Please try below. Change "-1" as per you deem fit.

https://docs.microsoft.com/en-us/dax/find-function-dax

 MID([IP_Sprint],FIND("@",[IP_Sprint],1,-1)+1,10) 

 

Thanks
Ankit Jain
Do Mark it as solution if the response resolved your problem. Do Kudo the response if it seems good and helpful.

 

 

 

 

@Anonymous

TomMartens
Super User
Super User

Hey @Anonymous ,

 

maybe you can adapt this formula to your needs:

PATHITEMREVERSE(SUBSTITUTE('Table'[the string] , "\" , "|") , 1 , TEXT)

The function SUBSTITUTE replaces all "\" with "|". The pipe sign | is used as a separator by all the PATH... functions. Then PATHITEMREVERSE takes the last item, by counting backwards.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Please see the attached file with few options for you to choose.

Measure, DAX Column and Power Query Column ( my prefered option )

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

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.