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 / Removing characters fr...
Power Automate
Unanswered

Removing characters from sting when creating a query

(0) ShareShare
ReportReport
Posted on by 28

I have had a look at similar topics and tried some of the suggestions but have not found a solution to the following problem -

 

I am trying to set up a flow which takes variables from PowerApps to send them to SharePoint list to filter the results so I can create a csv file in the flow, but I keep getting an error about the substring length, and can not remove the final 'and' from the compose stage.

 

The compose code is - 


concat(if(not(equals(variables('Room: Site'),'-')), concat('Room: Site eq ''', variables('Room: Site') ,''' and '),''),
if(not(equals(variables('Room: Building'),'-')), concat('Room: Building eq ''', variables('Room: Building') ,''' and '),''),
if(not(equals(variables('Room'),'-')), concat('Room eq ''', variables('Room') ,''' and '),''),
if(not(equals(variables('Equipment'),'-')), concat('Equipment eq ''', variables('Equipment') ,''''),'')

 

This returns an output with an 'and' on the end. So I have the following to try and remove the 'and' if it's there

 

if(endsWith(outputs('Compose'),' And '), substring(outputs('Compose'),sub(length(outputs('Compose')),5), length(outputs('Compose'))), outputs('Compose'))

 

However this doesn't seem to work, as I get the error that my substring can not be as long as my string.

 

Any help or advise welcome

Categories:
  • Hardesh15 Profile Picture
    7,087 Super User 2024 Season 1 on at

    @SMStevenson  Use replace() function and replace 'And' with '' (without space).

    replace(Outputs(Compose),'And','')

    Please 'Thumbs Up' the posts that helped you and 'Accept as Solution' if my post answered your question.

    @Hardesh /Gopenly.in

  • VictorIvanidze Profile Picture
    13,083 on at

    Could you show the values of each variable?

     

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 227 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 213 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 151

Last 30 days Overall leaderboard