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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / The second argument to...
Power Apps
Answered

The second argument to the 'Replace' function must be greater than or equal to 1

(0) ShareShare
ReportReport
Posted on by 7

Hi all, when enabling Formula-level error management I'm getting the error "The second argument to the 'Replace' function must be greater than or equal to 1"

 

The below formula is what it is referring to which appears to be working as expected. I didn't create the app originally but am maintaining it and I wanted to enable the error management to handle NULL values. Any ideas?

 

Concatenate(

    "Something went wrong with a previous attempt to save the report. Click below to go back to the report and check the following sections for completeness: ",

    Replace(lclMissingListItemNames,Len(lclMissingListItemNames)-1,Len(lclMissingListItemNames),".")

)

 

 

TIA

 

Paul

Categories:
I have the same question (0)
  • Verified answer
    CarlosFigueira Profile Picture
    Microsoft Employee on at

    As the error message suggests, the second parameter to the Replace function must be at least 1, so if the length of the lclMissingListItemNames variable is less than 2 (or it is blank, in which case it would have a length of 0), then you will see this error. With 'Formula-level error management' disabled you would get a blank value instead of the error. There are a few ways you can solve this:

    • "Capture" the error with the IfError function, and replace it with something else (such as Blank(), which was the previous result):
      • IfError(Replace(lclMissingListItemNames,Len(lclMissingListItemNames)-1,Len(lclMissingListItemNames),"."), Blank())
    • Check if the variable is large enough to do the replacement:
      • If(Len(lclMissingListItemNames) > 1, Replace(lclMissingListItemNames, Len(lclMissingListItemNames)-1, Len(lclMissingListItemNames),"."), Blank())

    Notice that you can simplify those expressions with the With function so that you won't need to repeat the same expression multiple times:

    • IfError(With({ l: Len(lclMissingListItemNames) }, Replace(lclMissingListItemNames, l - 1, l, "."), Blank()))
    • With({ l: Len(lclMissingListItemNames) }, If(l > 1, Replace(lclMissingListItemNames, l - 1, l, "."), Blank()))

    Hope this helps!

  • Paul_Owen Profile Picture
    7 on at

    Thanks Carlos solution helps tremendously and works perfectly.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 387

#2
timl Profile Picture

timl 340 Super User 2026 Season 1

#3
Vish WR Profile Picture

Vish WR 301

Last 30 days Overall leaderboard