Split cell value to columns and then select the last one ? each row have a varible number of elements

Hi,

I would like to split a structured “OU” -path, “\domain\OU\2nd_OU\3rd_OU\4th_OU\nth_OU” from a cell in each row to build a grouping. I would like to use the last OU string as a grouypby selection.

I can split it and put them in new columns, but how can I select always the last one and filter the rest out ?

Hi @miku,

Would you please provide a sample dataset and your desired output here?

What I have understood is that you need the last “OU” after the last backslash “”. But what is really the term there?

For now you could try this expression in a String Manipulation node:
regexReplace($column1$, ".*_", "")

This gives you the last term after “nth_”.

:blush:

Hi armingrudd,
sorry for the delay…

The OU is “Organizational Unit” from LDAP, so a sample would be like this:

Below is Active Directory OU structure, written down to single line paths for different OUs

Domain.com\Member Server\Country A\City A\Application\Role A
Domain.com\Member Server\Country A\City A\Application\Role B
Domain.com\Member Server\Country B\City B\Service B\Application\Role A
Domain.com\Member Server\Country AC\City C\Service C\Application\Role B
Domain.com\Workstations\Country A\City A\Office A
Domain.com\Workstations\Country A\City B\Office B\Win7
Domain.com\Workstations\Country A\City B\Office B\Win10

So the length and content is variable, I would like to select the last or sometimes any other part of that path… Sometimes the 3rd from the start (Country) or 4th for CIty and then Group_by with that info.

sorry for not being clear on the first post, but I hope this clears it up a bit ?

Thanks,
Miku

To get the leaf sub folder (the last one each time) you can try this inside a string manipulation node, where your list of directories is the $directory_column$

reverse(substr(reverse($directory_column$),0,indexOf(reverse($directory_column$),"\")))

2 Likes

Hi there @miku,

following @mrman100 reversing idea maybe you can try first reversing your column using reverse() function from String Manipulation node and then splitting. This way last part (OU) will always be in the first column :wink:

Hope this helps.

Br,
Ivan

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.