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 / Collection is removing...
Power Apps
Answered

Collection is removing my leading spaces

(0) ShareShare
ReportReport
Posted on by 11

I have a string coming from a flow that is pipe delimited and some of the value there should have leading space depends how many spaces the user entered. But after clearcollect and split functions, the leading spaces were automatically removed. I also tried to replace the space by "%" inside the flow and put the space back in PowerApps and same scenario happened.

How do I prevent the collection from removing my leading spaces? 

ClearCollect(
ColCSV,
Split(
varCSVFlow,
"|"
)


Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @bevik 

    You will need to look at the value in the varCSVFlow.  Split will not remove spaces.  Your ColCSV will have a single column table with a Result column and it will have the exact split based on the vertical bar/pipe that you have stated.  So, if there are no leading spaces, then there is an issue in the varCSVFlow.

     

    I hope this is helpful for you.

  • bevik Profile Picture
    11 on at

    Hi Randy, 

    I take a look each step, and you are right, it is not the collection. right after I received the string, the spaces are already gone.

    Here's the string from flow. The part where I need the spaces is in REC 1 part of the string.

    bevik_1-1621352241402.png

     


    This is the PowerApps received. 

    bevik_2-1621352371166.png

     

    This is after the split and I put it in Data Table. 

    bevik_3-1621352488353.png

     

    Now, I'm lost why the spaces are gone when the flow sends it with leading space. 😞

     

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @bevik 

    Yep...was wondering about this a bit as I've not had to deal with leading spaces as much as trailing spaces.

    It does indeed removing the leading spaces as you are seeing but ONLY in the viewers that you are looking at (i.e. the variable viewer)

    The fact is that the spaces are still there.

    To make sure I wasn't going crazy, I threw this in an app 

    Set(flowResult, "123, REC 1|dfg,dfg,dfg,df,dfg, REC 2");
    
    Set(xxx, ForAll(Split(flowResult, "|"),
     {Res: Last(Split(Result, ",")).Result, cnt: Len(Last(Split(Result, ",")).Result)}
     )
    );
    

    The variable viewer showed flowResult as: 

    RandyHayes_0-1621353339725.png

    It also showed the xxx variable as:

    RandyHayes_1-1621353406228.png

    NOTE from the formula above, that cnt was set to the count of letters in the Res column.  So for the first, it appears that it is just 5 letters, but the cnt shows it as 18.

    Placing the following in a label:

       "@" & First(xxx).Res

    Shows:

    RandyHayes_2-1621353492942.png

    So, the spaces are definitely there.

  • bevik Profile Picture
    11 on at

    Okay this is wrong in many ways, it mislead me to think that the data is incorrect in PowerApps and I can't continue my coding. Hoping the variable/collection viewer even the Data Table should have displayed it in original value without removing the leading spaces.

    but I'm glad that the spaces are still there. I tested the data by saving it in the sql table and the spaces were saved as well. 

     

    @RandyHayes 

    Thank you so much for helping me debug this, I really appreciate your quick reply.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @bevik 

    No problem at all.  Glad to help!

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 337 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 250

#3
Mohsin Ali Profile Picture

Mohsin Ali 225

Last 30 days Overall leaderboard