cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
dcullen
Level: Powered On

Splitting a string by a delimiter and getting the X result

 

 

I am trying to split the string "Hello | World" into an array words and then return the second result, which should be World.

 

I know how to split a string, but it's getting the result that I am struggling with.

 

Split("Hello | World", " |").Result

 

The above code will do the splittng and return a Table with two rows. I can get the Hello into a variable by using the First() function, but how can I get row X i.e. GetRow(MyTable, 2). Is there such a function?

 

Also, I know I can use Last() in this scenerio, but for instances where there are more than 2 results I would need a better solution.

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Meneghino
Level 10

Re: Splitting a string by a delimiter and getting the X result

Last(FirstN(Split("Hello | World", " |"), X)).Result

Where X is your rank.

Does this work?

7 REPLIES 7
Meneghino
Level 10

Re: Splitting a string by a delimiter and getting the X result

Last(FirstN(Split("Hello | World", " |"), X)).Result

Where X is your rank.

Does this work?

dcullen
Level: Powered On

Re: Splitting a string by a delimiter and getting the X result

This indeed does work, thanks!

 

Would be nice to have some kind of array like functions for pulling results from a table though.

 

i.e. Table.Result(3) 

Anonymous
Not applicable

Re: Splitting a string by a delimiter and getting the X result

This doesnt seem to work for me... FirstN is not a recognized function?

Meneghino
Level 10

Re: Splitting a string by a delimiter and getting the X result

AnshulS
Level: Powered On

Re: Splitting a string by a delimiter and getting the X result

Guys, i have a field which i have retrieved through an API named instanceData. 

I am getting this field in Dynamics content for further usage but the value that it has is something like this-- 

 

"instanceData": "{\"Microsoft.Resources\":{\"resourceUri\":\"/subscriptions/0000000000000000000000000000/resourceGroups/RGNAME/providers/Microsoft.Compute/virtualMachines/VMNAME\",\"location\":\"eastus\"}}}",

 

i just need this VMNAME value for my further process in the flow, so can i use this split function for this somehow? thanks in advance! 

dcullen
Level: Powered On

Re: Splitting a string by a delimiter and getting the X result

AnshulS
Level: Powered On

Re: Splitting a string by a delimiter and getting the X result

Hi @dcullen, appreciate the prompt response. I have already user Parse JSON action. Have attached the screenshot of it. Please let me know if i am missing something here.  Just a beginner!