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 / How to remove the last...
Power Automate
Answered

How to remove the last element of an array?

(0) ShareShare
ReportReport
Posted on by 6

How would a compose an output to remove the last element of an array? My specific use case would be to remove an extension from a file name..

 

For example, I have a file name called: this.is.a.test.txt

Desired output: this.is.a.test

 

Thanks!

Categories:
I have the same question (0)
  • EBMRay Profile Picture
    1,710 on at

    Hi @cchicken ,

     

    This expression might help you:

    substring(outputs('Compose'),0,sub(length(outputs('Compose')),4))

    I hope it helps!

    Regards,

    Julien 

  • cchicken Profile Picture
    6 on at

    @Julien2 

     

    I think this works. Can you briefly explain how this works? 

     

    Thank you!

  • EBMRay Profile Picture
    1,710 on at

    Hi @cchicken ,

     

    The substring function allows extracting part of a string. I have specified where to start at position 0 and how many characters I want.
    To find how many characters to take, I have used the length expression to give me the string length for the result.

     

    If I have answered your question, please mark your post as Solved.

    Thank you.

  • Verified answer
    DeepakS Profile Picture
    2,301 Most Valuable Professional on at

    Hi @cchicken 

     

    As @Julien2  suggested you should use substring function achieve this, I would prefer to add on the solution is to get the length of the last element dynamically:

    MyString is variable storing : this.is.a.test.txt (You can actually use any other string )

     

     
    substring(variables('MyString'),0,lastIndexOf(variables('MyString'),'.'))
     
    -------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

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

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard