Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Select a certain sub folder of a Path

Thordust16
7 - Meteor

Hello,

 

I have requirement where I have to parse a sub folder name from another input and select the path until that sub folder.

 

Directory.PNG

 

in row 2 I have to select path until sub folder Tree "C:\Users\Tree\"

in row 3 I have to select path until sub folder Egg Plant "C:\Users\Tree\Vegetable\Egg plant\"

 

Thanks in Advance

 

 

4 REPLIES 4
Claje
14 - Magnetar

Hi,


Take a look at the attached workflow and see if it helps.

 

I used a Formula to take the left characters until the Sub Directory was found, and then added that length + 1 (to include the last \).

MarqueeCrew
20 - Arcturus
20 - Arcturus

A different way to get there might be:

 

 

LEFT([directory], 
   Findstring([Directory],[Sub Folder])+length([Sub Folder])


 

 

          1         2         3
01234567890123456789012345678901234567890
----+----|-----+----|----+----|----+----|
C:\Users\Tree\Vegetable\Egg Plant\Tall

 Egg plant is found and should return:  24

Length of Egg plant is 9

 

That's 0-based and if you say LEFT(FIELD, 33) then it should be about right.

 

Cheers,

 

Mark

 

 

 

 

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Thordust16
7 - Meteor

Hi Mark,

 

It works like a charm when I use left function to get the path until that sub folder.

But when I try to use Right function to select a relative path to shorten my path it is not working. Is there a different work around..?

MarqueeCrew
20 - Arcturus
20 - Arcturus

i'm not in front of alteryx.....

 

  • I'd find the string before the sub folder using findstring
  • I'd find the sub folder plus anything beyond it using findstring
  • Strip off the C:\
  • replace all the characters that are not "\" with "."
  • replace "\.{3,}" with "\.." using a regex_replace
  • add the \sub directory at the end

Does that make sense?  There is likely an easier way, but this seems easiest to type on my phone.

 

Cheers,

 

Mark

 

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Labels