web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Can't use Replace func...
Power Automate
Unanswered

Can't use Replace function nested in Substring of to remove spaces

(0) ShareShare
ReportReport
Posted on by 19

Hi,

 

In a step of this flow, I need to search a Sharepoint Library for a file whose name contains (except for the spaces) the text in the 'Title' column of an Item of a Sharepoint list (available as dynamic content from previous step "Get an Item").

 

To check whether the text is contained, I'm using "substringof". I did some dummy testing with it to check that the function works ok for what I need, and everything was perfect. The problem comes when I try to solve the spaces issue. I'm trying to nest a replace function inside it, and I'm getting an error. See error "is not valid" below:

 

daniel27ad_work_3-1708374844510.png

daniel27ad_work_4-1708374951749.png

 

I'm able to use "replace" successfully with the same exact content if I use it outside of the "substringof". So the syntaxis of the replace function wouldn't seem to be the issue either.

 

If anyone knows whether I'm doing something wrong or if it's just that using a replace inside a substringof known to not work, I apreciate that you let me know.

 

Thanks!

 

 

 

Categories:
I have the same question (0)
  • creativeopinion Profile Picture
    10,502 Super User 2025 Season 2 on at

     I'm assuming you are using the Get files (properties only) action.Fun fact. The Get Files (properties only) returns folders as well. You need to use a Filter Query to return Files only. Refer to this YT Short.

     

    Your Filter Query is invalid. Your replace() function should be an expression. 

    It looks like you have a couple of nested Apply to Each actions. I can't quite tell what's going on... however you might also find this YT Tutorial helpful: 3 Mistakes YOU 🫵 are Making with the Apply to Each Action in your Microsoft Power Automate Flow

     

    In this video tutorial I’ll go over how to avoid these common mistakes when using the Apply to Each action in a Power Automate flow:

     

    1️⃣ Looping through a Single Item

    2️⃣ Creating Unnecessary Nested Loops

    3️⃣ Looping through an Unfiltered Array

     

    At the end of the video I share a few helpful insights when it comes to using the Apply to Each action in your flow.

    I'll also cover:

     How to avoid the Apply to Each action with a single item array

     How to use the item() function to access dynamic content in an array

     How to prevent unnecessary nested Apply to Each action loops

     How to use the Select action

     How to convert an array to a string with the Select action

    How to use the Filter Query field

     How to count the number of items in an array

     How to use a condition control

     How to use the concurrency control

     How to set a top count

     How to use Compose actions for troubleshooting

     

    -----

     

    For more flow troubleshooting tips—check out this YT Tutorial: 5 Power Automate Troubleshooting FAQs and Helpful Tips for Creating Better Flows

     

    In this tutorial I cover:

     

     How to troubleshoot a false Condition action result

     How to get dynamic content when it isn’t selectable from the list of dynamic content

     How to troubleshoot an Apply to Each action that isn’t looping through

     How to troubleshoot a skipped Apply to Each action

     How to troubleshoot a Filter Query

     How to use a SharePoint yes/no column in a Filter Query

     How to use Compose actions to troubleshoot a Power Automate flow

    How to troubleshoot multiple emails being sent

     How to troubleshoot multiple Teams messages being sent

     

    Hope this helps!


    If I helped you solve your problem—please mark my post as a solution .
    Consider giving me a 👍 if you liked my response! If you're feeling generous— ️  Buy me a coffee: https://www.buymeacoffee.com/acreativeopinion

    👉 Watch my tutorials on YouTube
    👉 Tips and Tricks on
    TikTok
     

    creativeopinion_0-1708381104901.png

    @daniel27ad_work

  • daniel27ad_work Profile Picture
    19 on at

    Thank you! This looks amazingly helpful. I'm relatively new on this world. From the moment I posted and before you replied I got to understand why "for each" is added automatically when I add certain types of actions: there's chance that there may be multiple files/rows meeting the criteria.

     

    I've tried adding the replace function in the way you showed, however, I get this message:

    daniel27ad_work_0-1708385023789.png

     

    I'll run through your videos. Thanks!

     

  • creativeopinion Profile Picture
    10,502 Super User 2025 Season 2 on at

    @daniel27ad_work The replace() function takes 3 parameters which are outlined in the tooltip when you insert the function.

    creativeopinion_0-1708390157413.png

    replace([string of text], [old text],[newtext])

    It looks like you are trying to use the Title from a SP list to see if it's located in your Get files (properties only) action—it's unclear because I can only see a portion of your flow. If that is the case, you need a Filter Array action as the Get Items action will always return an array of items. If you are trying to cross-reference items from a SharePoint list with files from a document library, you will need to use a Filter Array action to do so. 

     

    To learn more about how to use the Filter Array action, please refer to this YT Tutorial: Are you using the Microsoft Power Automate Filter Array Action wrong?

    In this video tutorial I’ll show you 3 practical ways to use the Filter Array action and how to use it properly.

    1️⃣ Cross-Referencing Data

    2️⃣ Filtering by Key

    3️⃣ Substring Matching

     

    Did you know that the Condition action has a limit of 10 conditions? Although it might look like the Filter Array action can only accept one condition—this is not true. By using the advanced mode you can enter multiple conditions into a Filter Array action with an expression.

     

    IN THIS VIDEO:

     3 Ways to Use the Filter Array Action

    How to use the Scope Action to Group Actions

    How to Check the Number of Items returned from a Filter Array Action

    How to Cross-Reference Data in Excel with a SharePoint List

     How the Filter Array Action Works

     How to Access the Dynamic Content from a Filter Array Action

     How to Filter Items by a Key

    How to Filter Items by Matching a Substring

    How to Use Multiple Conditions in a Filter Array Action

     

    Hope this helps!


    If I helped you solve your problem—please mark my post as a solution .
    Consider giving me a 👍 if you liked my response! If you're feeling generous— ️  Buy me a coffee: https://www.buymeacoffee.com/acreativeopinion

    👉 Watch my tutorials on YouTube
    👉 Tips and Tricks on TikTok
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard