cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Unkn0wn
Helper I
Helper I

getting folder path

I'm trying to retrieve folder path which is above 2 levels

i.e.

1. root folder/sub folder/abc/myFolder/subfolder1/finalfolder

2. root folder/sub folder/bcdf/myFolder/subfolder34/finalfolder

3. root folder/sub folder/dcedg/myFolder/subfolder999/finalfolder

 

now i want to get the value upto myFolder like 

1. root folder/sub folder/abc/myFolder

2. root folder/sub folder/bcdf/myFolder

3. root folder/sub folder/dcedg/myFolder

 

i tried substring and split but not able to get the exact context. any help here ?

1 REPLY 1
Expiscornovus
Super User
Super User

Hi @Unkn0wn,

 

First you could use split and length functions to count the number of nodes.

 

With if and greater functions you can check if it has 4 nodes (I am also counting the root folder/subfolder, that's why it isn't 2).

 

With take and join you can select only the first 4 nodes and join it back together as a proper folder path.

 

Below is an example of such an expression:

Replace the outputs('Compose') by your variable or field.

if(greater(length(split(outputs('Compose'), '/')), 4), join(take(split(outputs('Compose'), '/'), 4), '/'), outputs('Compose'))

 

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,100)