cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cardinaluk
Helper I
Helper I

Reading Comma Delimited string from multiline SharePoint column

I am saving a collection to a SharePoint multi-line column in an SP list. At the moment it saves as:

Developer,550,M365,375

The collection looks like:

collResources:
    {
     Role: 
     Rate:
    }

      

The text in bold is the role, above.

I need to use a ClearCollect to read this particular column and fill the collection. I've read this but it doesn't seem to fit my requirements exactly:

https://powerusers.microsoft.com/t5/Building-Power-Apps/Reading-values-in-a-comma-separated-string-a...

8 REPLIES 8
RandyHayes
Super User
Super User

@cardinaluk 

You can do this with a table producing function like ForAll.

Ex.

ClearCollect(
    colYours,
    With({_sp: Filter(Split(yourString, ","), !IsBlank(Result))},
        ForAll(Sequence(CountRows(_sp), 1, 2),
            {Role: Last(FirstN(_sp, Value)).Result,
             Rate: IfError(Value(Last(FirstN(_sp, Value + 1)).Result), 0)
            }
        )
    )
)
        

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Forgive me, but what would I replace yourString with? And how is it targeting the specific column in SharePoint? The column is called RatesCard, which I forgot to mention in my OP.

Thanks.

RandyHayes
Super User
Super User

@cardinaluk 

Well that is going to depend on your purpose.  

Are you wanting to collect values for one record based on those comma separated values in the column, or for all of the records in your datasource.  

I would need a little more context as to what you're trying to do to give more than a generic "yourString" in the formula.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi Randy,
I need to populate the role and rate columns in the collection.
Developer, is Role
550, is Rate
In the SPO column it looks like:
Developer,550,ProjMgr,375
All in one string.
I need to convert that to the collection
RandyHayes
Super User
Super User

@cardinaluk 

Yes, but what I am asking is - you mention this is in a column in your SharePoint list, but SharePoint is many records, not just a column.  So the question is - you need to convert just one record or all records, or specific records?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi,

Just the one record/item in the list.

Thanks for your help!

C

RandyHayes
Super User
Super User

@cardinaluk 

Then that would be the text to use - the lookup of that value:

ClearCollect(
    colYours,
    With({_sp: Filter(Split(LookUp(yourList, ID=<someID>, columnName), ","), !IsBlank(Result))},
        ForAll(Sequence(CountRows(_sp), 1, 2),
            {Role: Last(FirstN(_sp, Value)).Result,
             Rate: IfError(Value(Last(FirstN(_sp, Value + 1)).Result), 0)
            }
        )
    )
)

 

Now, unless you plan to add/remove or change these values in your app...I would skip the collection and just make it a variable:

Set(glbRateList,
    With({_sp: Filter(Split(LookUp(yourList, ID=<someID>, columnName), ","), !IsBlank(Result))},
        ForAll(Sequence(CountRows(_sp), 1, 2),
            {Role: Last(FirstN(_sp, Value)).Result,
             Rate: IfError(Value(Last(FirstN(_sp, Value + 1)).Result), 0)
            }
        )
    )
)

This will do the same thing, but not have the in-memory collection overhead to your app.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thanks. It's not reading it back correctly. Here is how it's submitting into the SPO column:

 

[{"Rate":550,"Role":"Developer"},{"Rate":750,"Role":"Fn Lead"}]

 

But when it reads it back it shows this in the collection:
coll.PNG

I'm using this to collect it from the column:

Clear(collResources);
ClearCollect(
    collResources,
    With({_sp: Filter(Split(LookUp(EngagementRequests, ID=Gallery1.Selected.ID, RatesCard), ","), !IsBlank(Result))},
        ForAll(Sequence(CountRows(_sp), 1, 2),
            {Role: Last(FirstN(_sp, Value)).Result,
             Rate: IfError(Value(Last(FirstN(_sp, Value + 1)).Result), 0)
            }
        )
    )
);

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (3,793)