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 / The expression is inva...
Power Automate
Unanswered

The expression is invalid error on length() formula.

(0) ShareShare
ReportReport
Posted on by

I'm trying to use all but the last character in a string variable, but Power Automate keeps giving me an "invalid expression" error, and I can't figure out why. Both these expressions give me the "Invalid expression" error...

length(variables('strHolding'))-1 //trying to put this into an integer variable
substring(variables('strHolding'),0,length(variables('strHolding'))-1) //trying to use this in a compose action

The strHolding variable contains a string that could be thousands of characters long, and it's always longer than 100 characters.

Categories:
I have the same question (0)
  • Verified answer
    Mira Ghaly Profile Picture
    11,413 Moderator on at

    @Anonymous 

    Please use below Expression

    substring(variables('strHolding'),0,sub(length(variables('strHolding')),1))
  • Community Power Platform Member Profile Picture
    on at

    Thank you, @Mira_Ghaly, this worked. I was not aware cardinal operators could not be used in Power Automate expressions.

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard