cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ML147243
Helper II
Helper II

Help building if statement in switch function

Hello,

 

I would like a file to move to a specific folder based on the original folder path. If it came from an onboarding folder, it will move to a similarly (but not always exactly) named onboarding folder in another library.

I have too many folders to achieve this with the nested conditional function and i'm not sure if I am using the Path or variables correctly. But this is what I have:

If([‘{Path}’]contains(variables(‘Emergency’),’1’, [if([‘{Path}’]contains(variables(‘Birthday’),’2’, [if([‘{Path}’]contains(variables(‘Computer’),’3’, [if([‘{Path}’]contains(variables(‘Dept’),’4’, [if([‘{Path}’]contains(variables(‘Engagement’),’5’, [if ([‘{Path}’]contains(variables(‘Goals’),’6’, [IF([‘{Path}’]contains(variables(‘Onboarding’),’7’, [if([‘{Path}’]contains(variables(‘Rounding’),’8’, [if([‘{Path}’]contains(variables(‘SOW’),’9’,[if ([‘{Path}’]contains(variables(‘Survey’),’10’, [if([‘{Path}’]contains(variables(‘Team’),’11’,””]]]]]]]]]])

 

 

2021-12-10_14-23-26.jpgThank you,

1 ACCEPTED SOLUTION

Accepted Solutions
v-chenzhi
Community Support
Community Support

Hi @ML147243 ,

 

Do you want to move files according to the Folder path?

Could you please tell me what the variables() mean?

I assume Variables() is the Path name and have a test on my side, please try the following workaround.

vchenzhi_0-1639449830267.png

Here is the expression:

if(contains(items('Apply_to_each')?['{Path}'],'Emergency'),1,
if(contains(items('Apply_to_each')?['{Path}'],'Birthday'),2,
if(contains(items('Apply_to_each')?['{Path}'],'Computer'),3,
if(contains(items('Apply_to_each')?['{Path}'],'Dept'),4,
if(contains(items('Apply_to_each')?['{Path}'],'Engagement'),5,
if(contains(items('Apply_to_each')?['{Path}'],'Goals'),6,
if(contains(items('Apply_to_each')?['{Path}'],'Onboarding'),7,
if(contains(items('Apply_to_each')?['{Path}'],'Rounding'),8,
if(contains(items('Apply_to_each')?['{Path}'],'SOW'),9,
if(contains(items('Apply_to_each')?['{Path}'],'Survey'),10,
if(contains(items('Apply_to_each')?['{Path}'],'Team'),11,12
)))))))))))

 

 

Best regards,

Zhi Chen

 

View solution in original post

3 REPLIES 3
v-chenzhi
Community Support
Community Support

Hi @ML147243 ,

 

Do you want to move files according to the Folder path?

Could you please tell me what the variables() mean?

I assume Variables() is the Path name and have a test on my side, please try the following workaround.

vchenzhi_0-1639449830267.png

Here is the expression:

if(contains(items('Apply_to_each')?['{Path}'],'Emergency'),1,
if(contains(items('Apply_to_each')?['{Path}'],'Birthday'),2,
if(contains(items('Apply_to_each')?['{Path}'],'Computer'),3,
if(contains(items('Apply_to_each')?['{Path}'],'Dept'),4,
if(contains(items('Apply_to_each')?['{Path}'],'Engagement'),5,
if(contains(items('Apply_to_each')?['{Path}'],'Goals'),6,
if(contains(items('Apply_to_each')?['{Path}'],'Onboarding'),7,
if(contains(items('Apply_to_each')?['{Path}'],'Rounding'),8,
if(contains(items('Apply_to_each')?['{Path}'],'SOW'),9,
if(contains(items('Apply_to_each')?['{Path}'],'Survey'),10,
if(contains(items('Apply_to_each')?['{Path}'],'Team'),11,12
)))))))))))

 

 

Best regards,

Zhi Chen

 

Hi @v-chenzhi , Yes I would like to move files based on their original folder path. 

I've tried your statement above and it moved the file into the default category instead of case 2. 

 

Are there limitations to the contains function in sharepoint?

I tried it again and it worked this time. Thank you.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,818)