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

The expression is invalid error on length() formula.

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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,415 Moderator on at

    @Anonymous 

    Please use below Expression

    substring(variables('strHolding'),0,sub(length(variables('strHolding')),1))
  • Community Power Platform Member Profile Picture
    Microsoft Employee 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 636

#2
Valantis Profile Picture

Valantis 372

#3
11manish Profile Picture

11manish 335

Last 30 days Overall leaderboard