Question

I want to extract the name of the file to another 6 columns.

For example, you want to put the "D" in the file name in the first column and the word "Berlin" in the second column, and so on.

I have already found a helpful solution with flows here in the forum, but I can't get any further with it.

I get the first part extracted, but it doesn't work from the second part on. I think I have a mistake in the definition of the formula/expression of the flow.

I hope you could help me.

Here are the steps I have done so far.

As you can see, the first five columns have " - " as delimiter and the last one only "-":

enter image description here

This my flow:

enter image description here

And here you will get the formula for part 1 (works) and 2 (doesn´t work):

Part 1 (extract the "D"):

substring(triggerBody()?['{Name}'], 0, IndexOf(triggerBody()?['{Name}'],' - '))

Part 2 (extract the "Berlin":

substring(triggerBody()?['{Name}'], add(IndexOf(triggerBody()?['{Name}'],' - '),1), sub(sub(length(triggerBody()?['{Name}']),IndexOf(triggerBody()?['{Name}'],' - ')),1))
Was it helpful?

Solution

You can use Compose action and Split function to extract the Filename string into substrings using the delimiter ' - '.

See the sample flow here: enter image description here

And the expressions are:

Compose: split(triggerOutputs()?['body/{Name}'],' - ')

D: outputs('Compose')[0]

Berlin: outputs('Compose')[1]

Note: Since you do not need the last substring “2020-q*”, I have left it un-splitted.


UPDATE:

To extract substrings from "2020-q*", you can add one more Compose action and two outputs from the second Compose action to the flow:

enter image description here

Expressions:

Compose2: split(outputs('2020-q*'),'-')

2020: outputs('Compose2')[0]

q*: outputs('Compose2')[1]

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top