cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

updating a table value based on comma separated value

Hi All, long time reader - first time question poser!

 

Scenario:

I have a comma separated string that is saved to a SPO list item. I want to identify if an item in this string is a match to an item in a collection and if so modify a value in the collection for example:

 

String = Choice 1, Choice3

Collection =    Selected  |  Choice Title

                        False           Choice 1

                        False           Choice 2

                        False           Choice 3

 

Desired Result:

Collection =    Selected  |  Choice Title

                        True            Choice 1

                        False           Choice 2

                        True            Choice 3

 

I thought:

//Put the string into a table

ClearCollect(Temp-Collection, Split(LookUp(SPO_List, ID = MatchedID, ColumnName),", "));

 

//If found in Temp-Collection then patch desired Collection

ForAll(Temp-Collection, patch(colDesiredCollection, lookup(colDesiredCollection, Title = ThisRecord.Result), {Selected: true}))

 

However the ThisRecord.Result doesn't work (the intellisense only offers .Selected and .Title) which are the options for colDesiredCollection and not the ForAll(Temp-Collection) i was expecting. Can anyone describe how to identify each item in a comma separated list and modify a collection? 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Anonymous 

Keep it super simple!!  

With({_item: LookUp(SPO_List, ID=MatchedID)},
    ClearCollect(Temp-Collection, 
        ForAll(Temp-Collection, {Title:Title, Selected: Title in _item}))
)

  

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!

View solution in original post

3 REPLIES 3
RandyHayes
Super User
Super User

@Anonymous 

Keep it super simple!!  

With({_item: LookUp(SPO_List, ID=MatchedID)},
    ClearCollect(Temp-Collection, 
        ForAll(Temp-Collection, {Title:Title, Selected: Title in _item}))
)

  

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!
Anonymous
Not applicable

@RandyHayes 

 

Thankyou for helping, sorry to say it isn't working (probably me doing something wrong or not explaining myself well enough!) 

 

A little further background might help:

I have a screen where the user is able to select from three checkboxes (these are gallery checkbox controls). When the items are saved I am sending them to SPO list as a comma separated string. What I am trying to achieve is the checkbox default to match the items in the comma string when the screen.visible occurs. 

 

So if I consider these as two seperate tables I have:

 

User Chooses:                                  Saved as:                                          Screen.Visible: 

Selected    |    Title                            CommaSeperatedString                  Split Function to Table

True               Choice 1                      e.g Choice 1, Choice 3                    Choice 1

False              Choice 2                                                                              Choice 3

True               Choice 3

 

What I want to do is toggle the true & false parts in the first table based on their title (or Result) in the second. When I try your previous suggestion, i either get a red squiggly under the _item in Selected: Title in _item or if mess around following the process I get true in all records (which is understandable). 

*modified to receive all True*

With({_item: LookUp(SPO_List, ID=MatchedID)},
      ClearCollect(Temp-Collection,
      ForAll(Temp_Collection, {Title:Title, Selected: Title in ThisRecord.Title}))
)

Anonymous
Not applicable

@RandyHayes very sorry, you were absolutely right, my mistake was that the SPO list actually needed a column name to return. So in correction and for future reference solution is:

 

With({_item: LookUp(SPO_List, ID=MatchedID, ColumnName)},
    ClearCollect(Temp-Collection, 
        ForAll(Temp-Collection, {Title:Title, Selected: Title in _item}))
)

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,618)