cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Resident Rockstar
Resident Rockstar

More OData help - simple left() right() text parsing routines.

This is so easy in excel... why the h these guys use this odata garbage, I will never know... but I am trying to do something very simple, in thought.  Can someone help me write the odata routine that I can put into a Set Variable action?

 

Column: Filename = 123456-r1.pdf

 

I need to set two variables from this same basic filename structure.

 

Variable: PartNumber

Variable: Revision

 

Partnumber = 123456 (all of the numbers up to and not including the "-")

 

Revision = 1 (the one or two digit number between the "r" and the ".")

 

In excel, I would write:

(A1)=123456R-r5.pdf

(A2)=SEARCH(".pdf",A1) = 11

(A3)=SEARCH("r",A1,A2-3) = 9

PartNumber=LEFT(A1,A3-2) = 123456R

Revision = MID(A1,A3+1,A2-A3-1) = 5

 

It would likely take me two full days to figure out all of the syntax required to do this simple task.  I beg for help from anyone that has some sympathy for my plight!

 

Thank you.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Resident Rockstar
Resident Rockstar

Ok, it took a bit less time than I expected.  Lucky this time.  Forunately, expression builder is more advanced than I thought.  It is still cryptic as hell.  I was blown away by the inability to do simple add/sub.  Had to wrap add() or sub() around things to do that.  wow...  What saved me wsa the lastIndexOf function.  The ability to search form the right made it much easier.

 

To find the last "r", I used Set Variabe "Find-r":  

lastIndexOf(body('Get_file_metadata')?['Name'],'r')

 

 To find the last ".", I used Set Variable "Find Dot":  

lastIndexOf(body('Get_file_metadata')?['Name'],'.')

 

To get part number, I wrote: 

substring(body('Get_file_metadata')?['Name'],0,add(variables('Find-r'),-1))

 

Toi get the revision number, I wrote: 

substring(body('Get_file_metadata')?['Name'],add(variables('Find-r'),1),sub(sub(lastIndexOf(body('Get_file_metadata')?['Name'],'.'),lastIndexOf(body('Get_file_metadata')?['Name'],'r')),1))

 

View solution in original post

2 REPLIES 2
Resident Rockstar
Resident Rockstar

Ok, it took a bit less time than I expected.  Lucky this time.  Forunately, expression builder is more advanced than I thought.  It is still cryptic as hell.  I was blown away by the inability to do simple add/sub.  Had to wrap add() or sub() around things to do that.  wow...  What saved me wsa the lastIndexOf function.  The ability to search form the right made it much easier.

 

To find the last "r", I used Set Variabe "Find-r":  

lastIndexOf(body('Get_file_metadata')?['Name'],'r')

 

 To find the last ".", I used Set Variable "Find Dot":  

lastIndexOf(body('Get_file_metadata')?['Name'],'.')

 

To get part number, I wrote: 

substring(body('Get_file_metadata')?['Name'],0,add(variables('Find-r'),-1))

 

Toi get the revision number, I wrote: 

substring(body('Get_file_metadata')?['Name'],add(variables('Find-r'),1),sub(sub(lastIndexOf(body('Get_file_metadata')?['Name'],'.'),lastIndexOf(body('Get_file_metadata')?['Name'],'r')),1))

 

View solution in original post

Nice solution... thank me very much!! 😄

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Microsoft Ignite

Microsoft Power Platform: 2021 Release Wave 1 Plan

Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (83,428)